Skip to main content

Builder

Struct Builder 

Source
pub struct Builder<A>
where A: Allocator,
{ /* private fields */ }
Expand description

A container used to build a message.

Implementations§

Source§

impl<A> Builder<A>
where A: Allocator,

Source

pub fn new(allocator: A) -> Self

Source

pub fn init_root<'a, T: FromPointerBuilder<'a>>(&'a mut self) -> T

Initializes the root as a value of the given type.

Source

pub fn initn_root<'a, T: FromPointerBuilder<'a>>(&'a mut self, length: u32) -> T

Initializes the root as a value of the given list type, with the given length.

Source

pub fn get_root<'a, T: FromPointerBuilder<'a>>(&'a mut self) -> Result<T>

Gets the root, interpreting it as the given type.

Source

pub fn get_root_as_reader<'a, T: FromPointerReader<'a>>(&'a self) -> Result<T>

Source

pub fn set_root<T: Owned>(&mut self, value: impl SetterInput<T>) -> Result<()>

Sets the root to a deep copy of the given value.

Source

pub fn set_root_canonical<T: Owned>( &mut self, value: impl SetterInput<T>, ) -> Result<()>

Sets the root to a canonicalized version of value. If this was the first action taken on this Builder, then a subsequent call to get_segments_for_output() should return a single segment, containing the full canonicalized message.

Source

pub fn get_segments_for_output(&self) -> OutputSegments<'_>

Source

pub fn into_reader(self) -> Reader<Self>

Source

pub fn into_typed<T: Owned>(self) -> TypedBuilder<T, A>

Source

pub fn into_allocator(self) -> A

Retrieves the underlying Allocator, deallocating all currently-allocated segments.

Source

pub fn size_in_words(&self) -> usize

Source§

impl Builder<HeapAllocator>

Source

pub fn new_default() -> Self

Constructs a new message::Builder<HeapAllocator> whose first segment has length SUGGESTED_FIRST_SEGMENT_WORDS.

Trait Implementations§

Source§

impl Default for Builder<HeapAllocator>

Available on crate feature alloc only.
Source§

fn default() -> Self

Constructs a new message::Builder<HeapAllocator> whose first segment has length SUGGESTED_FIRST_SEGMENT_WORDS.

Source§

impl<A, T> From<Builder<A>> for TypedReader<Builder<A>, T>
where A: Allocator, T: Owned,

Source§

fn from(message: Builder<A>) -> Self

Converts to this type from the input type.
Source§

impl<T, A> From<Builder<A>> for TypedBuilder<T, A>
where T: Owned, A: Allocator,

Source§

fn from(builder: Builder<A>) -> Self

Converts to this type from the input type.
Source§

impl<A> ReaderSegments for Builder<A>
where A: Allocator,

Source§

fn get_segment(&self, id: u32) -> Option<&[u8]>

Gets the segment with index idx. Returns None if idx is out of range. Read more
Source§

fn len(&self) -> usize

Gets the number of segments.
Source§

fn is_empty(&self) -> bool

Auto Trait Implementations§

§

impl<A> Freeze for Builder<A>

§

impl<A> RefUnwindSafe for Builder<A>

§

impl<A> Send for Builder<A>

§

impl<A> Sync for Builder<A>

§

impl<A> Unpin for Builder<A>

§

impl<A> UnsafeUnpin for Builder<A>

§

impl<A> UnwindSafe for Builder<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 = !

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

fn try_from(value: U) -> Result<T, !>

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.