Skip to main content

Bytes

Struct Bytes 

Source
pub struct Bytes<const N: usize>;
Expand description

A borrowed fixed-width span of wire bytes with no content interpretation.

N must be nonzero. Using Bytes<0> as a FixedCodec fails during constant evaluation rather than exposing a codec that violates FixedCodec::WIDTH.

use wire_repr::{Bytes, FixedCodec};

let _ = <Bytes<0> as FixedCodec>::WIDTH;

Bytes<N> decodes to the exact borrowed wire slice and plans an equally borrowed input slice for copying at write time. It does not validate magic values, reserved bytes, or any other domain semantics; consumers own those policies.

Trait Implementations§

Source§

impl<const N: usize> Clone for Bytes<N>

Source§

fn clone(&self) -> Bytes<N>

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 N: usize> Copy for Bytes<N>

Source§

impl<const N: usize> Debug for Bytes<N>

Source§

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

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

impl<const N: usize> Default for Bytes<N>

Source§

fn default() -> Bytes<N>

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

impl<const N: usize> Eq for Bytes<N>

Source§

impl<const N: usize> FixedCodec for Bytes<N>

Source§

const WIDTH: usize

Number of bytes in every encoded representation.
Source§

type Value<'wire> = &'wire [u8] where Self: 'wire

Semantic value represented by an exact-width wire representation.
Source§

type EncodeError = ExactWidthError

Error returned while preparing an encoded value.
Source§

type Plan<'value> = &'value [u8] where Self: 'value

Prepared fixed-width encoded bytes.
Source§

fn decode<'wire>(bytes: &'wire [u8]) -> Self::Value<'wire>

Decodes an exact-width encoded representation.
Source§

fn plan<'value>( value: Self::Value<'value>, ) -> Result<Self::Plan<'value>, Self::EncodeError>

Prepares the complete encoded representation without mutating a caller buffer.
Source§

impl<const N: usize> PartialEq for Bytes<N>

Source§

fn eq(&self, other: &Bytes<N>) -> bool

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

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

Inequality operator !=. Read more
Source§

impl<const N: usize> StructuralPartialEq for Bytes<N>

Auto Trait Implementations§

§

impl<const N: usize> Freeze for Bytes<N>

§

impl<const N: usize> RefUnwindSafe for Bytes<N>

§

impl<const N: usize> Send for Bytes<N>

§

impl<const N: usize> Sync for Bytes<N>

§

impl<const N: usize> Unpin for Bytes<N>

§

impl<const N: usize> UnsafeUnpin for Bytes<N>

§

impl<const N: usize> UnwindSafe for Bytes<N>

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