pub struct SegmentLengthsBuilder { /* private fields */ }
Expand description

Helper object for constructing an OwnedSegments or a SliceSegments.

Implementations§

source§

impl SegmentLengthsBuilder

source

pub fn with_capacity(capacity: usize) -> Self

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.

source

pub fn try_push_segment(&mut self, length_in_words: usize) -> Result<()>

Pushes a new segment length. The nth time (starting at 0) this is called specifies the length of the segment with ID n. If the segment overflows the total word count, then this returns a MessageSizeOverflow error.

source

pub fn into_owned_segments(self) -> OwnedSegments

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

source

pub fn into_slice_segments( self, slice: &[u8], segment_table_bytes_len: usize ) -> BufferSegments<&'_ [u8]>

Constructs a SliceSegments. slice contains the full message (including the segment header).

source

pub fn total_words(&self) -> usize

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

source

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

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§

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.