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 read_ref(&mut self, len: usize) -> &'a [u8]
Notable traits for &'_ mut [u8]
impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]
;
fn peek_ref(&self, len: usize) -> Option<&'a [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.

Reads a given length of bytes.

Panics

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.

Implementors