pub struct Bytes<'a> { /* private fields */ }
Expand description
A wrapper around &[u8]
to read more efficiently.
This has a specialized implementation of RmpWrite
and has error type Infallible.
This has the additional benefit of working on #[no_std]
(unlike the builtin Read trait)
See also serde_bytes::Bytes
Unlike a plain &[u8]
this also tracks an internal offset in the input (See Self::position
).
This is used for (limited) compatibility with std::io::Cursor
. Unlike a Cursor it does
not support mark/reset.
Implementations§
source§impl<'a> Bytes<'a>
impl<'a> Bytes<'a>
sourcepub fn new(bytes: &'a [u8]) -> Self
pub fn new(bytes: &'a [u8]) -> Self
Wrap an existing bytes slice.
This sets the internal position to zero.
sourcepub fn remaining_slice(&self) -> &'a [u8] ⓘ
pub fn remaining_slice(&self) -> &'a [u8] ⓘ
Get a reference to the remaining bytes in the buffer.
sourcepub fn position(&self) -> u64
pub fn position(&self) -> u64
Return the position of the input buffer.
This is not required for correctness, it only exists to help mimic
Cursor::position
Trait Implementations§
source§impl<'a> Ord for Bytes<'a>
impl<'a> Ord for Bytes<'a>
source§impl<'a> PartialEq for Bytes<'a>
impl<'a> PartialEq for Bytes<'a>
source§impl<'a> PartialOrd for Bytes<'a>
impl<'a> PartialOrd for Bytes<'a>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl<'a> Copy for Bytes<'a>
impl<'a> Eq for Bytes<'a>
impl<'a> StructuralPartialEq for Bytes<'a>
Auto Trait Implementations§
impl<'a> Freeze for Bytes<'a>
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)