Struct ObjectBuilder
pub struct ObjectBuilder<'a, S>where
S: BuilderSpecificState,{
parent_state: ParentState<'a, S>,
pub(crate) fields: IndexMap<u32, usize>,
validate_unique_fields: bool,
}Expand description
A builder for creating Variant::Object values.
See the examples on VariantBuilder for usage.
Fields§
§parent_state: ParentState<'a, S>§fields: IndexMap<u32, usize>§validate_unique_fields: boolImplementations§
§impl<'a, S> ObjectBuilder<'a, S>where
S: BuilderSpecificState,
impl<'a, S> ObjectBuilder<'a, S>where
S: BuilderSpecificState,
pub fn new(
parent_state: ParentState<'a, S>,
validate_unique_fields: bool,
) -> ObjectBuilder<'a, S>
pub fn new( parent_state: ParentState<'a, S>, validate_unique_fields: bool, ) -> ObjectBuilder<'a, S>
Creates a new object builder, nested on top of the given parent state.
pub fn insert<'m, 'd, T>(&mut self, key: &str, value: T)
pub fn insert<'m, 'd, T>(&mut self, key: &str, value: T)
Add a field with key and value to the object
§See Also
ObjectBuilder::try_insertfor a fallible version.ObjectBuilder::with_fieldfor a builder-style API.
§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
pub fn try_insert<'m, 'd, T>(
&mut self,
key: &str,
value: T,
) -> Result<(), ArrowError>
pub fn try_insert<'m, 'd, T>( &mut self, key: &str, value: T, ) -> Result<(), ArrowError>
Add a field with key and value to the object
§See Also
ObjectBuilder::insertfor an infallible version that panicsObjectBuilder::try_with_fieldfor a builder-style API.
§Note
Attempting to insert a duplicate field name produces an error if unique field validation is enabled. Otherwise, the new value overwrites the previous field mapping without erasing the old value, resulting in a larger variant
pub fn insert_bytes<'m, 'd>(
&mut self,
key: &str,
value: impl Into<Variant<'m, 'd>>,
)
pub fn insert_bytes<'m, 'd>( &mut self, key: &str, value: impl Into<Variant<'m, 'd>>, )
Add a field with key and value to the object by copying raw bytes when possible.
For objects and lists, this directly copies their underlying byte representation instead of performing a logical copy, and without touching the metadata builder. For other variant types, this falls back to the standard append behavior.
The caller must ensure that the metadata dictionary is already built and correct for any objects or lists being appended, but the value’s new field name is handled normally.
§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_bytes
pub fn try_insert_bytes<'m, 'd>(
&mut self,
key: &str,
value: impl Into<Variant<'m, 'd>>,
) -> Result<(), ArrowError>
pub fn try_insert_bytes<'m, 'd>( &mut self, key: &str, value: impl Into<Variant<'m, 'd>>, ) -> Result<(), ArrowError>
Add a field with key and value to the object by copying raw bytes when possible.
For objects and lists, this directly copies their underlying byte representation instead of performing a logical copy, and without touching the metadata builder. For other variant types, this falls back to the standard append behavior.
The caller must ensure that the metadata dictionary is already built and correct for any objects or lists being appended, but the value’s new field name is handled normally.
§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
pub fn with_field<'m, 'd, T>(self, key: &str, value: T) -> ObjectBuilder<'a, S>
pub fn with_field<'m, 'd, T>(self, key: &str, value: T) -> ObjectBuilder<'a, S>
Builder style API for adding a field with key and value to the object
Same as ObjectBuilder::insert, but returns self for chaining.
pub fn try_with_field<'m, 'd, T>(
self,
key: &str,
value: T,
) -> Result<ObjectBuilder<'a, S>, ArrowError>
pub fn try_with_field<'m, 'd, T>( self, key: &str, value: T, ) -> Result<ObjectBuilder<'a, S>, ArrowError>
Builder style API for adding a field with key and value to the object
Same as ObjectBuilder::try_insert, but returns self for chaining.
pub fn with_validate_unique_fields(
self,
validate_unique_fields: bool,
) -> ObjectBuilder<'a, S>
pub fn with_validate_unique_fields( self, validate_unique_fields: bool, ) -> ObjectBuilder<'a, S>
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.
pub fn new_object<'b>(
&'b mut self,
key: &'b str,
) -> ObjectBuilder<'b, ObjectState<'b>>
pub fn new_object<'b>( &'b mut self, key: &'b str, ) -> ObjectBuilder<'b, ObjectState<'b>>
Returns an object builder that can be used to append a new (nested) object to this object.
Panics if the proposed key was a duplicate
WARNING: The builder will have no effect unless/until ObjectBuilder::finish is called.
pub fn try_new_object<'b>(
&'b mut self,
key: &str,
) -> Result<ObjectBuilder<'b, ObjectState<'b>>, ArrowError>
pub fn try_new_object<'b>( &'b mut self, key: &str, ) -> Result<ObjectBuilder<'b, ObjectState<'b>>, ArrowError>
Returns an object builder that can be used to append a new (nested) object to this object.
Fails if the proposed key was a duplicate
WARNING: The builder will have no effect unless/until ObjectBuilder::finish is called.
pub fn new_list<'b>(&'b mut self, key: &str) -> ListBuilder<'b, ObjectState<'b>>
pub fn new_list<'b>(&'b mut self, key: &str) -> ListBuilder<'b, ObjectState<'b>>
Returns a list builder that can be used to append a new (nested) list to this object.
Panics if the proposed key was a duplicate
WARNING: The builder will have no effect unless/until ListBuilder::finish is called.
pub fn try_new_list<'b>(
&'b mut self,
key: &str,
) -> Result<ListBuilder<'b, ObjectState<'b>>, ArrowError>
pub fn try_new_list<'b>( &'b mut self, key: &str, ) -> Result<ListBuilder<'b, ObjectState<'b>>, ArrowError>
Returns a list builder that can be used to append a new (nested) list to this object.
Fails if the proposed key was a duplicate
WARNING: The builder will have no effect unless/until ListBuilder::finish is called.
pub fn finish(self)
pub fn finish(self)
Finalizes this object and appends it to its parent, which otherwise remains unmodified.
Trait Implementations§
§impl<'a, S> Debug for ObjectBuilder<'a, S>where
S: Debug + BuilderSpecificState,
impl<'a, S> Debug for ObjectBuilder<'a, S>where
S: Debug + BuilderSpecificState,
§impl<'a, 'm, 'v, S, K, V> Extend<(K, V)> for ObjectBuilder<'a, S>
impl<'a, 'm, 'v, S, K, V> Extend<(K, V)> for ObjectBuilder<'a, S>
§fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = (K, V)>,
fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = (K, V)>,
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Auto Trait Implementations§
impl<'a, S> Freeze for ObjectBuilder<'a, S>where
S: Freeze,
impl<'a, S> !RefUnwindSafe for ObjectBuilder<'a, S>
impl<'a, S> !Send for ObjectBuilder<'a, S>
impl<'a, S> !Sync for ObjectBuilder<'a, S>
impl<'a, S> Unpin for ObjectBuilder<'a, S>where
S: Unpin,
impl<'a, S> !UnwindSafe for ObjectBuilder<'a, S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more