pub struct ListBuilder<'a> {
parent_state: ParentState<'a>,
offsets: Vec<usize>,
buffer: ValueBuffer,
validate_unique_fields: bool,
}
Expand description
A builder for creating Variant::List
values.
See the examples on VariantBuilder
for usage.
Fields§
§parent_state: ParentState<'a>
§offsets: Vec<usize>
§buffer: ValueBuffer
§validate_unique_fields: bool
Implementations§
Source§impl<'a> ListBuilder<'a>
impl<'a> ListBuilder<'a>
fn new(parent_state: ParentState<'a>, validate_unique_fields: bool) -> Self
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 unique field key validation for objects created within this list.
Propagates the validation flag to any ObjectBuilder
s created using
ListBuilder::new_object
.
fn parent_state(&mut self) -> (ParentState<'_>, bool)
Sourcepub fn new_object(&mut self) -> ObjectBuilder<'_>
pub fn new_object(&mut self) -> ObjectBuilder<'_>
Returns an object builder that can be used to append a new (nested) object to this list.
WARNING: The builder will have no effect unless/until ObjectBuilder::finish
is called.
Sourcepub fn new_list(&mut self) -> ListBuilder<'_>
pub fn new_list(&mut self) -> ListBuilder<'_>
Returns a list builder that can be used to append a new (nested) list to this list.
WARNING: The builder will have no effect unless/until ListBuilder::finish
is called.
Sourcepub fn append_value<'m, 'd, T: Into<Variant<'m, 'd>>>(&mut self, value: T)
pub fn append_value<'m, 'd, T: Into<Variant<'m, 'd>>>(&mut self, value: T)
Appends a variant to the list.
§Panics
This method will panic if the variant contains duplicate field names in objects
when validation is enabled. For a fallible version, use ListBuilder::try_append_value
.
Trait Implementations§
Source§impl Drop for ListBuilder<'_>
Drop implementation for ListBuilder does nothing
as the finish
method must be called to finalize the list.
This is to ensure that the list is always finalized before its parent builder
is finalized.
impl Drop for ListBuilder<'_>
Drop implementation for ListBuilder does nothing
as the finish
method must be called to finalize the list.
This is to ensure that the list is always finalized before its parent builder
is finalized.