Bytes

Struct Bytes 

Source
pub struct Bytes<'a, const N: usize, B>
where B: AsRef<[u8]>,
{ /* private fields */ }
Expand description

§Bytes

This struct can be converted from:

  • A single slice of bytes.
  • A slice of slices of bytes.
  • An array of slices of bytes.

You rarely use this struct directly. Some functions in this project look like below example:

use zeros::Bytes;

fn some<'a, const N: usize, B, B0>(bytes: B)
where B: Into<Bytes<'a, N, B0>>, B0: AsRef<[u8]> + 'a {
}

some("data");
some(["test", "data"]);
some([0, 1, 2]);
some(&[[3, 4, 5], [6, 7, 8]][..]);

So it’s just a convenient way for you to provide your data to those functions.

Trait Implementations§

Source§

impl<'a, const N: usize, B> Debug for Bytes<'a, N, B>
where B: AsRef<[u8]> + Debug,

Source§

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

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

impl<'a, B> From<&'a [B]> for Bytes<'a, { usize::MIN }, B>
where B: AsRef<[u8]>,

Source§

fn from(bytes: &'a [B]) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize, B> From<[B; N]> for Bytes<'_, N, B>
where B: AsRef<[u8]>,

Source§

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

Converts to this type from the input type.
Source§

impl<B> From<B> for Bytes<'_, 1, B>
where B: AsRef<[u8]>,

Source§

fn from(bytes: B) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a, const N: usize, B> Freeze for Bytes<'a, N, B>
where B: Freeze,

§

impl<'a, const N: usize, B> RefUnwindSafe for Bytes<'a, N, B>
where B: RefUnwindSafe,

§

impl<'a, const N: usize, B> Send for Bytes<'a, N, B>
where B: Send + Sync,

§

impl<'a, const N: usize, B> Sync for Bytes<'a, N, B>
where B: Sync,

§

impl<'a, const N: usize, B> Unpin for Bytes<'a, N, B>
where B: Unpin,

§

impl<'a, const N: usize, B> UnwindSafe for Bytes<'a, N, B>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.