Skip to main content

Bytes

Struct Bytes 

Source
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>

Source

pub const fn new() -> Self

Source

pub fn from_slice(bytes: &[u8]) -> Result<Self, Error>

Source

pub fn try_reserve(&mut self, amount: usize) -> Result<Append<'_, L>, Error>

Reserves an exact region or returns its precise capacity shortfall.

Source

pub fn fit(&mut self, amount: usize) -> Append<'_, L>

Reserves the largest prefix up to amount that currently fits.

Source

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.

Source

pub fn truncate(&mut self, len: usize)

Source

pub fn clear(&mut self)

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn available(&self) -> usize

Source

pub fn backing_mut(&mut self) -> &mut [u8; CAP]

Returns the complete initialized backing without changing its prefix.

Trait Implementations§

Source§

impl<const CAP: usize, L: Length> AsMut<[u8]> for Bytes<CAP, L>

Source§

fn as_mut(&mut self) -> &mut [u8] ⓘ

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<const CAP: usize, L: Length> AsRef<[u8]> for Bytes<CAP, L>

Source§

fn as_ref(&self) -> &[u8] ⓘ

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<const CAP: usize, L: Clone> Clone for Bytes<CAP, L>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<const CAP: usize, L: Copy> Copy for Bytes<CAP, L>

Source§

impl<const CAP: usize, L: Debug> Debug for Bytes<CAP, L>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const CAP: usize, L: Length> Default for Bytes<CAP, L>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<const CAP: usize, L: Length> Eq for Bytes<CAP, L>

Source§

impl<'a, const MAX: usize> From<&'a Bytes<MAX>> for Prefix<'a, MAX>

Source§

fn from(bytes: &'a Bytes<MAX>) -> Self

Converts to this type from the input type.
Source§

impl<const CAP: usize, L: Length> From<Prefix<'_, CAP>> for Bytes<CAP, L>

Source§

fn from(source: Prefix<'_, CAP>) -> Self

Converts to this type from the input type.
Source§

impl<const CAP: usize, L: Length, const N: usize> From<[u8; N]> for Bytes<CAP, L>

Source§

fn from(bytes: [u8; N]) -> Self

Converts to this type from the input type.
Source§

impl<const CAP: usize, L: Length> Hash for Bytes<CAP, L>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<const CAP: usize, L: Length> PartialEq for Bytes<CAP, L>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<const CAP: usize, L> Residency for Bytes<CAP, L>

Source§

fn resident(&self) -> usize

Source§

impl<const CAP: usize, L: Length> Sink for Bytes<CAP, L>

Source§

type Error = Error

Source§

fn write_slice(&mut self, bytes: &[u8]) -> Result<(), Self::Error>

Source§

fn write_slices<const N: usize>( &mut self, slices: [&[u8]; N], ) -> Result<(), Self::Error>

Source§

fn write_byte(&mut self, byte: u8) -> Result<(), Self::Error>

Source§

impl<const CAP: usize, L> Source for Bytes<CAP, L>
where Bytes<CAP, L>: AsRef<[u8]>,

Auto Trait Implementations§

§

impl<const CAP: usize, L> Forget for Bytes<CAP, L>

§

impl<const CAP: usize, L> Freeze for Bytes<CAP, L>
where [u8; CAP]: Freeze, L: Freeze,

§

impl<const CAP: usize, L> RefUnwindSafe for Bytes<CAP, L>

§

impl<const CAP: usize, L> Send for Bytes<CAP, L>
where [u8; CAP]: Send, L: Send,

§

impl<const CAP: usize, L> Sync for Bytes<CAP, L>
where [u8; CAP]: Sync, L: Sync,

§

impl<const CAP: usize, L> Unpin for Bytes<CAP, L>
where [u8; CAP]: Unpin, L: Unpin,

§

impl<const CAP: usize, L> UnsafeUnpin for Bytes<CAP, L>
where [u8; CAP]: UnsafeUnpin, L: UnsafeUnpin,

§

impl<const CAP: usize, L> UnwindSafe for Bytes<CAP, L>
where [u8; CAP]: UnwindSafe, L: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Convert<T> for T

Source§

fn into(self) -> T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.