FixedBytes

Struct FixedBytes 

Source
pub struct FixedBytes<const N: usize> { /* private fields */ }
Expand description

A fixed-size bytes storage which keeps track of how much has been initialized.

Implementations§

Source§

impl<const N: usize> FixedBytes<N>

Source

pub const fn new() -> FixedBytes<N>

Construct a new fixed bytes array storage.

Source

pub const fn len(&self) -> usize

Get the length of the collection.

Source

pub const fn is_empty(&self) -> bool

Test if the current container is empty.

Source

pub fn clear(&mut self)

Clear the FixedBytes container.

Source

pub const fn remaining(&self) -> usize

Get the remaining capacity of the FixedBytes.

Source

pub fn into_bytes(self) -> Option<[u8; N]>

Coerce into the underlying bytes if all of them have been initialized.

Source

pub fn as_slice(&self) -> &[u8]

Coerce into the slice of initialized memory which is present.

Source

pub fn as_mut_slice(&mut self) -> &[u8]

Coerce into the mutable slice of initialized memory which is present.

Source

pub fn push(&mut self, value: u8) -> bool

Try and push a single byte.

Source

pub fn extend_from_slice(&mut self, source: &[u8]) -> bool

Try and extend from the given slice.

Source

pub fn write_bytes<C>( &mut self, cx: &mut C, source: &[u8], ) -> Result<(), <C as Context>::Error>
where C: Context<Input = FixedBytesOverflow>,

Try and extend from the given slice.

Trait Implementations§

Source§

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

Source§

fn default() -> FixedBytes<N>

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

impl<const N: usize> Writer for FixedBytes<N>

Source§

type Error = FixedBytesOverflow

The error type raised by the writer.
Source§

type Mut<'this> = &'this mut FixedBytes<N> where FixedBytes<N>: 'this

Reborrowed type. Read more
Source§

fn borrow_mut(&mut self) -> <FixedBytes<N> as Writer>::Mut<'_>

Reborrow the current type.
Source§

fn write_buffer<C, B>( &mut self, cx: &mut C, buffer: B, ) -> Result<(), <C as Context>::Error>
where C: Context<Input = <FixedBytes<N> as Writer>::Error>, B: Buffer,

Write a buffer to the current writer.
Source§

fn write_bytes<C>( &mut self, cx: &mut C, bytes: &[u8], ) -> Result<(), <C as Context>::Error>
where C: Context<Input = <FixedBytes<N> as Writer>::Error>,

Write bytes to the current writer.
Source§

fn write_array<C, const U: usize>( &mut self, cx: &mut C, array: [u8; U], ) -> Result<(), <C as Context>::Error>
where C: Context<Input = <FixedBytes<N> as Writer>::Error>,

Write an array to the current writer.
Source§

fn write_byte<C>( &mut self, cx: &mut C, b: u8, ) -> Result<(), <C as Context>::Error>
where C: Context<Input = Self::Error>,

Write a single byte.

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<const N: usize> UnwindSafe for FixedBytes<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> 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V