Struct capnp::message::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§

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>

source§

fn default() -> Self

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

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

source§

impl<A> Send for Builder<A>
where A: Send + Allocator,

Auto Trait Implementations§

§

impl<A> Freeze for Builder<A>
where A: Freeze,

§

impl<A> RefUnwindSafe for Builder<A>
where A: RefUnwindSafe,

§

impl<A> !Sync for Builder<A>

§

impl<A> Unpin for Builder<A>
where A: Unpin,

§

impl<A> UnwindSafe for Builder<A>
where A: UnwindSafe,

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

§

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

§

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.