pub trait BytesReadRef<'a>: BytesRead {
    fn as_slice_ref(&self) -> &'a [u8]Notable traits for &'_ mut [u8]impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8];
    fn remaining_ref(&self) -> &'a [u8]Notable traits for &'_ mut [u8]impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8];
    fn try_read_ref(&mut self, len: usize) -> Result<&'a [u8], ReadError>;
    fn peek_ref(&self, len: usize) -> Option<&'a [u8]>;

    fn read_ref(&mut self, len: usize) -> &'a [u8]Notable traits for &'_ mut [u8]impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8] { ... }
}
Expand description

Read bytes while keeping the original reference.

use simple_bytes::{Bytes, BytesRead, BytesReadRef};

let mut bytes = Bytes::from("hey".as_ref());
let h = bytes.read_u8();
let ey: &'static [u8] = bytes.remaining_ref();

Required Methods

Returns the entire slice.

Returns all remaining bytes.

Try to read a given length of bytes.

Failes

If len exceeds self.remaining().len().

Tries to read a given length without updating the internal position. Returns None if there are not enought bytes remaining.

Provided Methods

Reads a given length of bytes.

Panics

If len exceeds self.remaining().len().

Implementors