pub struct ObjectBuilder<'a> {
parent_state: ParentState<'a>,
fields: IndexMap<u32, usize>,
buffer: ValueBuffer,
validate_unique_fields: bool,
duplicate_fields: HashSet<u32>,
}
Expand description
A builder for creating Variant::Object
values.
See the examples on VariantBuilder
for usage.
Fields§
§parent_state: ParentState<'a>
§fields: IndexMap<u32, usize>
§buffer: ValueBuffer
§validate_unique_fields: bool
§duplicate_fields: HashSet<u32>
Set of duplicate fields to report for errors
Implementations§
Source§impl<'a> ObjectBuilder<'a>
impl<'a> ObjectBuilder<'a>
fn new(parent_state: ParentState<'a>, validate_unique_fields: bool) -> Self
Sourcepub fn insert<'m, 'd, T: Into<Variant<'m, 'd>>>(&mut self, key: &str, value: T)
pub fn insert<'m, 'd, T: Into<Variant<'m, 'd>>>(&mut self, key: &str, value: T)
Add a field with key and value to the object
§Panics
This method will panic if the variant contains duplicate field names in objects
when validation is enabled. For a fallible version, use ObjectBuilder::try_insert
Sourcepub fn try_insert<'m, 'd, T: Into<Variant<'m, 'd>>>(
&mut self,
key: &str,
value: T,
) -> Result<(), ArrowError>
pub fn try_insert<'m, 'd, T: Into<Variant<'m, 'd>>>( &mut self, key: &str, value: T, ) -> Result<(), ArrowError>
Add a field with key and value to the object
Note: when inserting duplicate keys, the new value overwrites the previous mapping, but the old value remains in the buffer, resulting in a larger variant
Sourcepub fn with_validate_unique_fields(self, validate_unique_fields: bool) -> Self
pub fn with_validate_unique_fields(self, validate_unique_fields: bool) -> Self
Enables validation for unique field keys when inserting into this object.
When this is enabled, calling ObjectBuilder::finish
will return an error
if any duplicate field keys were added using ObjectBuilder::insert
.
fn parent_state<'b>(&'b mut self, key: &'b str) -> (ParentState<'b>, bool)
Sourcepub fn new_object<'b>(&'b mut self, key: &'b str) -> ObjectBuilder<'b>
pub fn new_object<'b>(&'b mut self, key: &'b str) -> ObjectBuilder<'b>
Returns an object builder that can be used to append a new (nested) object to this object.
WARNING: The builder will have no effect unless/until ObjectBuilder::finish
is called.
Sourcepub fn new_list<'b>(&'b mut self, key: &'b str) -> ListBuilder<'b>
pub fn new_list<'b>(&'b mut self, key: &'b str) -> ListBuilder<'b>
Returns a list builder that can be used to append a new (nested) list to this object.
WARNING: The builder will have no effect unless/until ListBuilder::finish
is called.
Trait Implementations§
Source§impl Drop for ObjectBuilder<'_>
Drop implementation for ObjectBuilder does nothing
as the finish
method must be called to finalize the object.
This is to ensure that the object is always finalized before its parent builder
is finalized.
impl Drop for ObjectBuilder<'_>
Drop implementation for ObjectBuilder does nothing
as the finish
method must be called to finalize the object.
This is to ensure that the object is always finalized before its parent builder
is finalized.