pub struct Bytes<const CAP: usize = { CAPACITY }, L = u8> { /* private fields */ }Expand description
Fixed-capacity owned bytes with an integer prefix length.
Implementations§
Source§impl<const CAP: usize, L: Length> Bytes<CAP, L>
impl<const CAP: usize, L: Length> Bytes<CAP, L>
pub const fn new() -> Self
pub fn from_slice(bytes: &[u8]) -> Result<Self, Error>
Sourcepub fn try_reserve(&mut self, amount: usize) -> Result<Append<'_, L>, Error>
pub fn try_reserve(&mut self, amount: usize) -> Result<Append<'_, L>, Error>
Reserves an exact region or returns its precise capacity shortfall.
Sourcepub fn fit(&mut self, amount: usize) -> Append<'_, L>
pub fn fit(&mut self, amount: usize) -> Append<'_, L>
Reserves the largest prefix up to amount that currently fits.
Sourcepub fn try_replace<const N: usize>(
&mut self,
start: usize,
limit: usize,
slices: [&[u8]; N],
) -> Result<(), Error>
pub fn try_replace<const N: usize>( &mut self, start: usize, limit: usize, slices: [&[u8]; N], ) -> Result<(), Error>
Replaces the suffix after start, admitting every source within limit.
Both bounds are clamped to this owner’s initialized length and capacity.
Rejection leaves the complete backing and initialized length unchanged.
pub fn truncate(&mut self, len: usize)
pub fn clear(&mut self)
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn available(&self) -> usize
Sourcepub fn backing_mut(&mut self) -> &mut [u8; CAP]
pub fn backing_mut(&mut self) -> &mut [u8; CAP]
Returns the complete initialized backing without changing its prefix.
Trait Implementations§
impl<const CAP: usize, L: Copy> Copy for Bytes<CAP, L>
impl<const CAP: usize, L: Length> Eq for Bytes<CAP, L>
impl<const CAP: usize, L> Source for Bytes<CAP, L>
Auto Trait Implementations§
impl<const CAP: usize, L> Forget for Bytes<CAP, L>
impl<const CAP: usize, L> Freeze for Bytes<CAP, L>
impl<const CAP: usize, L> RefUnwindSafe for Bytes<CAP, L>
impl<const CAP: usize, L> Send for Bytes<CAP, L>
impl<const CAP: usize, L> Sync for Bytes<CAP, L>
impl<const CAP: usize, L> Unpin for Bytes<CAP, L>
impl<const CAP: usize, L> UnsafeUnpin for Bytes<CAP, L>
impl<const CAP: usize, L> UnwindSafe for Bytes<CAP, L>
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