Struct capnp::serialize::SegmentLengthsBuilder[][src]

pub struct SegmentLengthsBuilder { /* fields omitted */ }

Helper object for constructing an OwnedSegments or a SliceSegments.

Implementations

impl SegmentLengthsBuilder[src]

pub fn with_capacity(capacity: usize) -> Self[src]

Creates a new SegmentsLengthsBuilder, initializing the segment_indices vector with Vec::with_capacitiy(capacity). capacity should equal the number of times that push_segment() is expected to be called.

pub fn push_segment(&mut self, length_in_words: usize)[src]

Pushes a new segment length. The nth time (starting at 0) this is called specifies the length of the segment with ID n.

pub fn into_owned_segments(self) -> OwnedSegments[src]

Constructs an OwnedSegments, allocating a single buffer of 8-byte aligned memory to hold all segments.

pub fn into_slice_segments(self, slice: &[u8]) -> SliceSegments<'_>[src]

Constructs a SliceSegments, where the passed-in slice is assumed to contain the segments.

pub fn total_words(&self) -> usize[src]

Returns the sum of the lengths of the segments pushed so far.

pub fn to_segment_indices(self) -> Vec<(usize, usize)>[src]

Returns the vector of segment indices. Each entry is a pair (start_word_index, end_word_index). This method primarily exists to enable testing.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.