pub struct BufferReader<B> { /* private fields */ }
Implementations§
Source§impl<B: SplitByteSlice> BufferReader<B>
impl<B: SplitByteSlice> BufferReader<B>
pub fn new(bytes: B) -> Self
pub fn read<T>(&mut self) -> Option<Ref<B, T>>where
T: Unaligned + KnownLayout + Immutable + FromBytes,
pub fn read_unaligned<T>(&mut self) -> Option<UnalignedView<B, T>>where
T: FromBytes + Immutable,
pub fn peek<T>(&self) -> Option<Ref<&[u8], T>>where
T: Unaligned + Immutable + KnownLayout + FromBytes,
pub fn peek_unaligned<T>(&self) -> Option<UnalignedView<&[u8], T>>where
T: FromBytes + Immutable,
pub fn read_array<T>(&mut self, num_elems: usize) -> Option<Ref<B, [T]>>where
T: Unaligned + FromBytes + Immutable,
pub fn peek_array<T>(&self, num_elems: usize) -> Option<Ref<&[u8], [T]>>where
T: Unaligned + FromBytes + Immutable,
pub fn read_byte(&mut self) -> Option<u8>
pub fn peek_byte(&mut self) -> Option<u8>
Sourcepub fn read_value<T>(&mut self) -> Option<T>where
T: FromBytes + Immutable + Copy,
pub fn read_value<T>(&mut self) -> Option<T>where
T: FromBytes + Immutable + Copy,
Useful for reading integers.
Example:
let mut reader = BufferReader::new(&vec![1, 2, 3]);
let val = reader.read_value::<u16>();
assert_eq!(Some(1 + 256 * 2), val);
pub fn peek_value<T>(&self) -> Option<T>where
T: FromBytes + Immutable + Copy,
pub fn read_bytes(&mut self, len: usize) -> Option<B>
pub fn peek_bytes(&self, len: usize) -> Option<&[u8]>
pub fn peek_remaining(&self) -> &[u8] ⓘ
pub fn bytes_read(&self) -> usize
pub fn bytes_remaining(&self) -> usize
pub fn into_remaining(self) -> B
Source§impl<B: SplitByteSliceMut> BufferReader<B>
impl<B: SplitByteSliceMut> BufferReader<B>
pub fn peek_mut<T>(&mut self) -> Option<Ref<&mut [u8], T>>where
T: Unaligned + FromBytes + Immutable + KnownLayout,
pub fn peek_mut_unaligned<T>(&mut self) -> Option<UnalignedView<&mut [u8], T>>where
T: FromBytes + KnownLayout + Immutable,
pub fn peek_array_mut<T>(
&mut self,
num_elems: usize,
) -> Option<Ref<&mut [u8], [T]>>where
T: Unaligned + FromBytes + Immutable,
pub fn peek_bytes_mut(&mut self, len: usize) -> Option<&mut [u8]>
pub fn peek_remaining_mut(&mut self) -> &mut [u8] ⓘ
Trait Implementations§
Source§impl<B: SplitByteSlice> IntoBufferReader<B> for BufferReader<B>
impl<B: SplitByteSlice> IntoBufferReader<B> for BufferReader<B>
fn into_buffer_reader(self) -> BufferReader<B>
Auto Trait Implementations§
impl<B> Freeze for BufferReader<B>where
B: Freeze,
impl<B> RefUnwindSafe for BufferReader<B>where
B: RefUnwindSafe,
impl<B> Send for BufferReader<B>where
B: Send,
impl<B> Sync for BufferReader<B>where
B: Sync,
impl<B> Unpin for BufferReader<B>where
B: Unpin,
impl<B> UnwindSafe for BufferReader<B>where
B: UnwindSafe,
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