Struct ObjectBuilder

Source
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>

Source

fn new(parent_state: ParentState<'a>, validate_unique_fields: bool) -> Self

Source

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

Source

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

Source

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.

Source

fn parent_state<'b>(&'b mut self, key: &'b str) -> (ParentState<'b>, bool)

Source

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.

Source

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.

Source

pub fn finish(self) -> Result<(), ArrowError>

Finalizes this object and appends it to its parent, which otherwise remains unmodified.

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.

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for ObjectBuilder<'a>

§

impl<'a> RefUnwindSafe for ObjectBuilder<'a>

§

impl<'a> Send for ObjectBuilder<'a>

§

impl<'a> Sync for ObjectBuilder<'a>

§

impl<'a> Unpin for ObjectBuilder<'a>

§

impl<'a> !UnwindSafe for ObjectBuilder<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.