pub struct ReadCursor<'a> { /* private fields */ }
Expand description
A cursor for reading bytes from a buffer.
Implementations§
Source§impl<'a> ReadCursor<'a>
impl<'a> ReadCursor<'a>
Sourcepub const fn split_at_peek(
&self,
mid: usize,
) -> (ReadCursor<'a>, ReadCursor<'a>)
pub const fn split_at_peek( &self, mid: usize, ) -> (ReadCursor<'a>, ReadCursor<'a>)
Returns two cursors, one with the first mid
bytes and the other with the remaining bytes.
Sourcepub fn split_at(&mut self, mid: usize) -> (ReadCursor<'a>, ReadCursor<'a>)
pub fn split_at(&mut self, mid: usize) -> (ReadCursor<'a>, ReadCursor<'a>)
Returns two cursors, one with the first mid
bytes and the other with the remaining bytes.
The current cursor will be moved to the end.
Sourcepub fn read_array<const N: usize>(&mut self) -> [u8; N]
pub fn read_array<const N: usize>(&mut self) -> [u8; N]
Read an array of N
bytes.
Sourcepub fn read_slice(&mut self, n: usize) -> &'a [u8]
pub fn read_slice(&mut self, n: usize) -> &'a [u8]
Read a slice of n
bytes.
Sourcepub fn read_remaining(&mut self) -> &[u8]
pub fn read_remaining(&mut self) -> &[u8]
Read the remaining bytes.
Sourcepub fn try_read_u8(&mut self) -> Result<u8, NotEnoughBytesError>
pub fn try_read_u8(&mut self) -> Result<u8, NotEnoughBytesError>
Try to read a u8
.
Sourcepub fn read_i16_be(&mut self) -> i16
pub fn read_i16_be(&mut self) -> i16
Read a i16
in big-endian.
Sourcepub fn try_read_i16(&mut self) -> Result<i16, NotEnoughBytesError>
pub fn try_read_i16(&mut self) -> Result<i16, NotEnoughBytesError>
Try to read a i16
.
Sourcepub fn try_read_i16_be(&mut self) -> Result<i16, NotEnoughBytesError>
pub fn try_read_i16_be(&mut self) -> Result<i16, NotEnoughBytesError>
Try to read a i16
in big-endian.
Sourcepub fn read_u16_be(&mut self) -> u16
pub fn read_u16_be(&mut self) -> u16
Read a u16
in big-endian.
Sourcepub fn try_read_u16(&mut self) -> Result<u16, NotEnoughBytesError>
pub fn try_read_u16(&mut self) -> Result<u16, NotEnoughBytesError>
Try to read a u16
.
Sourcepub fn try_read_u16_be(&mut self) -> Result<u16, NotEnoughBytesError>
pub fn try_read_u16_be(&mut self) -> Result<u16, NotEnoughBytesError>
Try to read a u16
in big-endian.
Sourcepub fn read_u32_be(&mut self) -> u32
pub fn read_u32_be(&mut self) -> u32
Read a u32
in big-endian.
Sourcepub fn try_read_u32(&mut self) -> Result<u32, NotEnoughBytesError>
pub fn try_read_u32(&mut self) -> Result<u32, NotEnoughBytesError>
Try to read a u32
.
Sourcepub fn try_read_u32_be(&mut self) -> Result<u32, NotEnoughBytesError>
pub fn try_read_u32_be(&mut self) -> Result<u32, NotEnoughBytesError>
Try to read a u32
in big-endian.
Sourcepub fn read_u64_be(&mut self) -> u64
pub fn read_u64_be(&mut self) -> u64
Read a u64
in big-endian.
Sourcepub fn try_read_u64(&mut self) -> Result<u64, NotEnoughBytesError>
pub fn try_read_u64(&mut self) -> Result<u64, NotEnoughBytesError>
Try to read a u64
.
Sourcepub fn try_read_u64_be(&mut self) -> Result<u64, NotEnoughBytesError>
pub fn try_read_u64_be(&mut self) -> Result<u64, NotEnoughBytesError>
Try to read a u64
in big-endian.
Sourcepub fn read_i32_be(&mut self) -> i32
pub fn read_i32_be(&mut self) -> i32
Read a i32
in big-endian.
Sourcepub fn try_read_i32(&mut self) -> Result<i32, NotEnoughBytesError>
pub fn try_read_i32(&mut self) -> Result<i32, NotEnoughBytesError>
Try to read a i32
.
Sourcepub fn try_read_i32_be(&mut self) -> Result<i32, NotEnoughBytesError>
pub fn try_read_i32_be(&mut self) -> Result<i32, NotEnoughBytesError>
Try to read a i32
in big-endian.
Sourcepub fn read_i64_be(&mut self) -> i64
pub fn read_i64_be(&mut self) -> i64
Read a i64
in big-endian.
Sourcepub fn try_read_i64(&mut self) -> Result<i64, NotEnoughBytesError>
pub fn try_read_i64(&mut self) -> Result<i64, NotEnoughBytesError>
Try to read a i64
.
Sourcepub fn try_read_i64_be(&mut self) -> Result<i64, NotEnoughBytesError>
pub fn try_read_i64_be(&mut self) -> Result<i64, NotEnoughBytesError>
Try to read a i64
in big-endian.
Sourcepub fn read_u128_be(&mut self) -> u128
pub fn read_u128_be(&mut self) -> u128
Read a u128
in big-endian.
Sourcepub fn try_read_u128(&mut self) -> Result<u128, NotEnoughBytesError>
pub fn try_read_u128(&mut self) -> Result<u128, NotEnoughBytesError>
Try to read a u128
.
Sourcepub fn try_read_u128_be(&mut self) -> Result<u128, NotEnoughBytesError>
pub fn try_read_u128_be(&mut self) -> Result<u128, NotEnoughBytesError>
Try to read a u128
in big-endian.
Sourcepub fn peek<const N: usize>(&mut self) -> [u8; N]
pub fn peek<const N: usize>(&mut self) -> [u8; N]
Peek at the next N
bytes without consuming them.
Sourcepub fn peek_slice(&mut self, n: usize) -> &'a [u8]
pub fn peek_slice(&mut self, n: usize) -> &'a [u8]
Peek at the next N
bytes without consuming them.
Sourcepub fn try_peek_u8(&mut self) -> Result<u8, NotEnoughBytesError>
pub fn try_peek_u8(&mut self) -> Result<u8, NotEnoughBytesError>
Try to peek a u8
without consuming it.
Sourcepub fn peek_u16_be(&mut self) -> u16
pub fn peek_u16_be(&mut self) -> u16
Peek a big-endian u16
without consuming it.
Sourcepub fn try_peek_u16(&mut self) -> Result<u16, NotEnoughBytesError>
pub fn try_peek_u16(&mut self) -> Result<u16, NotEnoughBytesError>
Try to peek a u16
without consuming it.
Sourcepub fn try_peek_u16_be(&mut self) -> Result<u16, NotEnoughBytesError>
pub fn try_peek_u16_be(&mut self) -> Result<u16, NotEnoughBytesError>
Try to peek a big-endian u16
without consuming it.
Sourcepub fn peek_u32_be(&mut self) -> u32
pub fn peek_u32_be(&mut self) -> u32
Peek a big-endian u32
without consuming it.
Sourcepub fn try_peek_u32(&mut self) -> Result<u32, NotEnoughBytesError>
pub fn try_peek_u32(&mut self) -> Result<u32, NotEnoughBytesError>
Try to peek a u32
without consuming it.
Sourcepub fn try_peek_u32_be(&mut self) -> Result<u32, NotEnoughBytesError>
pub fn try_peek_u32_be(&mut self) -> Result<u32, NotEnoughBytesError>
Try to peek a big-endian u32
without consuming it.
Sourcepub fn peek_u64_be(&mut self) -> u64
pub fn peek_u64_be(&mut self) -> u64
Peek a big-endian u64
without consuming it.
Sourcepub fn try_peek_u64(&mut self) -> Result<u64, NotEnoughBytesError>
pub fn try_peek_u64(&mut self) -> Result<u64, NotEnoughBytesError>
Try to peek a u64
without consuming it.
Sourcepub fn try_peek_u64_be(&mut self) -> Result<u64, NotEnoughBytesError>
pub fn try_peek_u64_be(&mut self) -> Result<u64, NotEnoughBytesError>
Try to peek a big-endian u64
without consuming it.
Sourcepub const fn advanced(&'a self, len: usize) -> ReadCursor<'a>
pub const fn advanced(&'a self, len: usize) -> ReadCursor<'a>
Return a new cursor advanced by len
bytes.
Sourcepub const fn rewinded(&'a self, len: usize) -> ReadCursor<'a>
pub const fn rewinded(&'a self, len: usize) -> ReadCursor<'a>
Return a new cursor rewinded by len
bytes.
Trait Implementations§
Source§impl<'a> Clone for ReadCursor<'a>
impl<'a> Clone for ReadCursor<'a>
Source§fn clone(&self) -> ReadCursor<'a>
fn clone(&self) -> ReadCursor<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more