pub struct SliceReader<'a> { /* private fields */ }Expand description
A zero-copy, advancing reader for byte slices.
Implementations§
Source§impl<'a> SliceReader<'a>
impl<'a> SliceReader<'a>
pub fn new(slice: &'a [u8]) -> Self
Sourcepub fn read_bytes(&mut self, len: usize) -> DcbResult<&'a [u8]>
pub fn read_bytes(&mut self, len: usize) -> DcbResult<&'a [u8]>
Safely takes len bytes from the front and advances the internal slice.
pub fn read_u8(&mut self) -> DcbResult<u8>
pub fn read_u16(&mut self) -> DcbResult<u16>
pub fn read_u32(&mut self) -> DcbResult<u32>
pub fn read_u64(&mut self) -> DcbResult<u64>
pub fn read_uuid(&mut self) -> DcbResult<Uuid>
pub fn read_page_id(&mut self) -> DcbResult<PageID>
pub fn read_position(&mut self) -> DcbResult<Position>
pub fn read_tsn(&mut self) -> DcbResult<Tsn>
Sourcepub fn read_str(&mut self, len: usize) -> DcbResult<&'a str>
pub fn read_str(&mut self, len: usize) -> DcbResult<&'a str>
Safely reads len bytes and validates them as a zero-copy UTF-8 string reference.
Sourcepub fn read_string(&mut self, len: usize) -> DcbResult<String>
pub fn read_string(&mut self, len: usize) -> DcbResult<String>
Safely reads len bytes and allocates them into an owned String.
Sourcepub fn read_tag_hash(&mut self) -> DcbResult<[u8; 16]>
pub fn read_tag_hash(&mut self) -> DcbResult<[u8; 16]>
Reads a dynamically sized tag hash from disk and zero-pads it to the in-memory size.
Auto Trait Implementations§
impl<'a> Freeze for SliceReader<'a>
impl<'a> RefUnwindSafe for SliceReader<'a>
impl<'a> Send for SliceReader<'a>
impl<'a> Sync for SliceReader<'a>
impl<'a> Unpin for SliceReader<'a>
impl<'a> UnsafeUnpin for SliceReader<'a>
impl<'a> UnwindSafe for SliceReader<'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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more