pub enum RawData<'a> {
Single(&'a [u8]),
Split(&'a [u8], &'a [u8]),
}
Expand description
A slice of u8 data that can have non-contiguous backing storage split into two pieces, and abstracts that split away so that users can pretend to deal with a contiguous slice.
When reading perf events from the mmap’d fd that contains the perf event stream, it often happens that a single record straddles the boundary between two mmap chunks, or is wrapped from the end to the start of a chunk.
Variants§
Implementations§
Source§impl<'a> RawData<'a>
impl<'a> RawData<'a>
pub fn empty() -> Self
pub fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
pub fn read_u64<T: ByteOrder>(&mut self) -> Result<u64, Error>
pub fn read_u32<T: ByteOrder>(&mut self) -> Result<u32, Error>
pub fn read_i32<T: ByteOrder>(&mut self) -> Result<i32, Error>
pub fn read_u16<T: ByteOrder>(&mut self) -> Result<u16, Error>
pub fn read_u8(&mut self) -> Result<u8, Error>
Sourcepub fn read_string(&mut self) -> Option<RawData<'a>>
pub fn read_string(&mut self) -> Option<RawData<'a>>
Finds the first nul byte. Returns everything before that nul byte. Sets self to everything after the nul byte.
Sourcepub fn split_off_prefix(&mut self, n: usize) -> Result<Self, Error>
pub fn split_off_prefix(&mut self, n: usize) -> Result<Self, Error>
Returns the first n
bytes, and sets self to the remainder.
pub fn skip(&mut self, n: usize) -> Result<(), Error>
pub fn as_slice(&self) -> Cow<'a, [u8]>
pub fn get(&self, range: Range<usize>) -> Option<RawData<'a>>
pub fn is_empty(&self) -> bool
pub fn len(&self) -> usize
Trait Implementations§
impl<'a> Copy for RawData<'a>
impl<'a> Eq for RawData<'a>
impl<'a> StructuralPartialEq for RawData<'a>
Auto Trait Implementations§
impl<'a> Freeze for RawData<'a>
impl<'a> RefUnwindSafe for RawData<'a>
impl<'a> Send for RawData<'a>
impl<'a> Sync for RawData<'a>
impl<'a> Unpin for RawData<'a>
impl<'a> UnwindSafe for RawData<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more