Trait capnp::message::ReaderSegments
source · [−]pub trait ReaderSegments {
fn get_segment<'a>(&'a self, idx: u32) -> Option<&'a [u8]>;
fn len(&self) -> usize { ... }
}
Expand description
An object that manages the buffers underlying a Cap’n Proto message reader.
Required Methods
fn get_segment<'a>(&'a self, idx: u32) -> Option<&'a [u8]>
fn get_segment<'a>(&'a self, idx: u32) -> Option<&'a [u8]>
Gets the segment with index idx
. Returns None
if idx
is out of range.
The segment must be 8-byte aligned or the “unaligned” feature must be enabled in the capnp crate. (Otherwise reading the segment will return an error.)
The returned slice is required to point to memory that remains valid until the ReaderSegments object is dropped. In safe Rust, it should not be possible to violate this requirement.