Struct capnp::serialize::SegmentLengthsBuilder [−][src]
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 n
th 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
impl RefUnwindSafe for SegmentLengthsBuilder
impl Send for SegmentLengthsBuilder
impl Sync for SegmentLengthsBuilder
impl Unpin for SegmentLengthsBuilder
impl UnwindSafe for SegmentLengthsBuilder
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,