Struct simple_bytes::Bytes
source · pub struct Bytes<'a> { /* private fields */ }
Expand description
A slice wrapper that implements BytesRead.
Implementations§
Trait Implementations§
source§impl BytesRead for Bytes<'_>
impl BytesRead for Bytes<'_>
source§fn try_read(&mut self, len: usize) -> Result<&[u8], ReadError>
fn try_read(&mut self, len: usize) -> Result<&[u8], ReadError>
Try to read a given length of bytes. Read more
source§fn peek(&self, len: usize) -> Option<&[u8]>
fn peek(&self, len: usize) -> Option<&[u8]>
Tries to read a given length without updating
the internal position. Returns
None
if there are not enought
bytes remaining.source§fn try_read_u8(&mut self) -> Result<u8, ReadError>
fn try_read_u8(&mut self) -> Result<u8, ReadError>
Try to read
1
bytes in big-endian converting them into an
u8
.source§fn try_read_u16(&mut self) -> Result<u16, ReadError>
fn try_read_u16(&mut self) -> Result<u16, ReadError>
Try to read
2
bytes in big-endian converting them into an
u16
.source§fn read_u16(&mut self) -> u16
fn read_u16(&mut self) -> u16
Reads
2
bytes in big-endian converting them into an
u16
. Read moresource§fn try_read_u32(&mut self) -> Result<u32, ReadError>
fn try_read_u32(&mut self) -> Result<u32, ReadError>
Try to read
4
bytes in big-endian converting them into an
u32
.source§fn read_u32(&mut self) -> u32
fn read_u32(&mut self) -> u32
Reads
4
bytes in big-endian converting them into an
u32
. Read moresource§fn try_read_u64(&mut self) -> Result<u64, ReadError>
fn try_read_u64(&mut self) -> Result<u64, ReadError>
Try to read
8
bytes in big-endian converting them into an
u64
.source§fn read_u64(&mut self) -> u64
fn read_u64(&mut self) -> u64
Reads
8
bytes in big-endian converting them into an
u64
. Read moresource§fn try_read_u128(&mut self) -> Result<u128, ReadError>
fn try_read_u128(&mut self) -> Result<u128, ReadError>
Try to read
16
bytes in big-endian converting them into an
u128
.source§fn read_u128(&mut self) -> u128
fn read_u128(&mut self) -> u128
Reads
16
bytes in big-endian converting them into an
u128
. Read moresource§fn try_read_i8(&mut self) -> Result<i8, ReadError>
fn try_read_i8(&mut self) -> Result<i8, ReadError>
Try to read
1
bytes in big-endian converting them into an
i8
.source§fn try_read_i16(&mut self) -> Result<i16, ReadError>
fn try_read_i16(&mut self) -> Result<i16, ReadError>
Try to read
2
bytes in big-endian converting them into an
i16
.source§fn read_i16(&mut self) -> i16
fn read_i16(&mut self) -> i16
Reads
2
bytes in big-endian converting them into an
i16
. Read moresource§fn try_read_i32(&mut self) -> Result<i32, ReadError>
fn try_read_i32(&mut self) -> Result<i32, ReadError>
Try to read
4
bytes in big-endian converting them into an
i32
.source§fn read_i32(&mut self) -> i32
fn read_i32(&mut self) -> i32
Reads
4
bytes in big-endian converting them into an
i32
. Read moresource§fn try_read_i64(&mut self) -> Result<i64, ReadError>
fn try_read_i64(&mut self) -> Result<i64, ReadError>
Try to read
8
bytes in big-endian converting them into an
i64
.source§fn read_i64(&mut self) -> i64
fn read_i64(&mut self) -> i64
Reads
8
bytes in big-endian converting them into an
i64
. Read moresource§fn try_read_i128(&mut self) -> Result<i128, ReadError>
fn try_read_i128(&mut self) -> Result<i128, ReadError>
Try to read
16
bytes in big-endian converting them into an
i128
.source§fn read_i128(&mut self) -> i128
fn read_i128(&mut self) -> i128
Reads
16
bytes in big-endian converting them into an
i128
. Read moresource§fn try_read_f32(&mut self) -> Result<f32, ReadError>
fn try_read_f32(&mut self) -> Result<f32, ReadError>
Try to read
4
bytes in big-endian converting them into an
f32
.source§fn read_f32(&mut self) -> f32
fn read_f32(&mut self) -> f32
Reads
4
bytes in big-endian converting them into an
f32
. Read moresource§fn try_read_f64(&mut self) -> Result<f64, ReadError>
fn try_read_f64(&mut self) -> Result<f64, ReadError>
Try to read
8
bytes in big-endian converting them into an
f64
.source§fn read_f64(&mut self) -> f64
fn read_f64(&mut self) -> f64
Reads
8
bytes in big-endian converting them into an
f64
. Read moresource§fn try_read_le_u8(&mut self) -> Result<u8, ReadError>
fn try_read_le_u8(&mut self) -> Result<u8, ReadError>
Try to read
1
bytes in little-endian converting them into an
u8
.source§fn read_le_u8(&mut self) -> u8
fn read_le_u8(&mut self) -> u8
Reads
1
bytes in little-endian converting them into an
u8
. Read moresource§fn try_read_le_u16(&mut self) -> Result<u16, ReadError>
fn try_read_le_u16(&mut self) -> Result<u16, ReadError>
Try to read
2
bytes in little-endian converting them into an
u16
.source§fn read_le_u16(&mut self) -> u16
fn read_le_u16(&mut self) -> u16
Reads
2
bytes in little-endian converting them into an
u16
. Read moresource§fn try_read_le_u32(&mut self) -> Result<u32, ReadError>
fn try_read_le_u32(&mut self) -> Result<u32, ReadError>
Try to read
4
bytes in little-endian converting them into an
u32
.source§fn read_le_u32(&mut self) -> u32
fn read_le_u32(&mut self) -> u32
Reads
4
bytes in little-endian converting them into an
u32
. Read moresource§fn try_read_le_u64(&mut self) -> Result<u64, ReadError>
fn try_read_le_u64(&mut self) -> Result<u64, ReadError>
Try to read
8
bytes in little-endian converting them into an
u64
.source§fn read_le_u64(&mut self) -> u64
fn read_le_u64(&mut self) -> u64
Reads
8
bytes in little-endian converting them into an
u64
. Read moresource§fn try_read_le_u128(&mut self) -> Result<u128, ReadError>
fn try_read_le_u128(&mut self) -> Result<u128, ReadError>
Try to read
16
bytes in little-endian converting them into an
u128
.source§fn read_le_u128(&mut self) -> u128
fn read_le_u128(&mut self) -> u128
Reads
16
bytes in little-endian converting them into an
u128
. Read moresource§fn try_read_le_i8(&mut self) -> Result<i8, ReadError>
fn try_read_le_i8(&mut self) -> Result<i8, ReadError>
Try to read
1
bytes in little-endian converting them into an
i8
.source§fn read_le_i8(&mut self) -> i8
fn read_le_i8(&mut self) -> i8
Reads
1
bytes in little-endian converting them into an
i8
. Read moresource§fn try_read_le_i16(&mut self) -> Result<i16, ReadError>
fn try_read_le_i16(&mut self) -> Result<i16, ReadError>
Try to read
2
bytes in little-endian converting them into an
i16
.source§fn read_le_i16(&mut self) -> i16
fn read_le_i16(&mut self) -> i16
Reads
2
bytes in little-endian converting them into an
i16
. Read moresource§fn try_read_le_i32(&mut self) -> Result<i32, ReadError>
fn try_read_le_i32(&mut self) -> Result<i32, ReadError>
Try to read
4
bytes in little-endian converting them into an
i32
.source§fn read_le_i32(&mut self) -> i32
fn read_le_i32(&mut self) -> i32
Reads
4
bytes in little-endian converting them into an
i32
. Read moresource§fn try_read_le_i64(&mut self) -> Result<i64, ReadError>
fn try_read_le_i64(&mut self) -> Result<i64, ReadError>
Try to read
8
bytes in little-endian converting them into an
i64
.source§fn read_le_i64(&mut self) -> i64
fn read_le_i64(&mut self) -> i64
Reads
8
bytes in little-endian converting them into an
i64
. Read moresource§fn try_read_le_i128(&mut self) -> Result<i128, ReadError>
fn try_read_le_i128(&mut self) -> Result<i128, ReadError>
Try to read
16
bytes in little-endian converting them into an
i128
.source§fn read_le_i128(&mut self) -> i128
fn read_le_i128(&mut self) -> i128
Reads
16
bytes in little-endian converting them into an
i128
. Read moresource§fn try_read_le_f32(&mut self) -> Result<f32, ReadError>
fn try_read_le_f32(&mut self) -> Result<f32, ReadError>
Try to read
4
bytes in little-endian converting them into an
f32
.source§fn read_le_f32(&mut self) -> f32
fn read_le_f32(&mut self) -> f32
Reads
4
bytes in little-endian converting them into an
f32
. Read moresource§fn try_read_le_f64(&mut self) -> Result<f64, ReadError>
fn try_read_le_f64(&mut self) -> Result<f64, ReadError>
Try to read
8
bytes in little-endian converting them into an
f64
.source§fn read_le_f64(&mut self) -> f64
fn read_le_f64(&mut self) -> f64
Reads
8
bytes in little-endian converting them into an
f64
. Read moresource§impl<'a> BytesReadRef<'a> for Bytes<'a>
impl<'a> BytesReadRef<'a> for Bytes<'a>
source§fn as_slice_ref(&self) -> &'a [u8] ⓘ
fn as_slice_ref(&self) -> &'a [u8] ⓘ
Returns the entire slice.
source§fn remaining_ref(&self) -> &'a [u8] ⓘ
fn remaining_ref(&self) -> &'a [u8] ⓘ
Returns all remaining bytes.
source§fn try_read_ref(&mut self, len: usize) -> Result<&'a [u8], ReadError>
fn try_read_ref(&mut self, len: usize) -> Result<&'a [u8], ReadError>
Try to read a given length of bytes. Read more
source§impl BytesSeek for Bytes<'_>
impl BytesSeek for Bytes<'_>
source§impl<'a> PartialEq<Bytes<'a>> for Bytes<'a>
impl<'a> PartialEq<Bytes<'a>> for Bytes<'a>
source§impl Read for Bytes<'_>
impl Read for Bytes<'_>
source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
Pull some bytes from this source into the specified buffer, returning
how many bytes were read. Read more
1.36.0 · source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
Like
read
, except that it reads into a slice of buffers. Read moresource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector
)1.0.0 · source§fn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>
Read all bytes until EOF in this source, placing them into
buf
. Read more1.0.0 · source§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
Read all bytes until EOF in this source, appending them to
buf
. Read more1.6.0 · source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
Read the exact number of bytes required to fill
buf
. Read moresource§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
read_buf
)Pull some bytes from this source into the specified buffer. Read more
source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
read_buf
)Read the exact number of bytes required to fill
cursor
. Read more1.0.0 · source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere Self: Sized,
Creates a “by reference” adaptor for this instance of
Read
. Read moresource§impl Seek for Bytes<'_>
impl Seek for Bytes<'_>
source§fn seek(&mut self, pos: SeekFrom) -> Result<u64>
fn seek(&mut self, pos: SeekFrom) -> Result<u64>
Seek to an offset, in bytes, in a stream. Read more
1.55.0 · source§fn rewind(&mut self) -> Result<(), Error>
fn rewind(&mut self) -> Result<(), Error>
Rewind to the beginning of a stream. Read more
impl<'a> Copy for Bytes<'a>
impl<'a> Eq for Bytes<'a>
impl<'a> StructuralEq for Bytes<'a>
impl<'a> StructuralPartialEq for Bytes<'a>
Auto Trait Implementations§
impl<'a> RefUnwindSafe for Bytes<'a>
impl<'a> Send for Bytes<'a>
impl<'a> Sync for Bytes<'a>
impl<'a> Unpin for Bytes<'a>
impl<'a> UnwindSafe for Bytes<'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