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>
impl<const N: usize> FixedBytes<N>
Sourcepub const fn new() -> FixedBytes<N>
pub const fn new() -> FixedBytes<N>
Construct a new fixed bytes array storage.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clear the FixedBytes container.
Sourcepub const fn remaining(&self) -> usize
pub const fn remaining(&self) -> usize
Get the remaining capacity of the FixedBytes.
Sourcepub fn into_bytes(self) -> Option<[u8; N]>
pub fn into_bytes(self) -> Option<[u8; N]>
Coerce into the underlying bytes if all of them have been initialized.
Sourcepub fn as_slice(&self) -> &[u8] ⓘ
pub fn as_slice(&self) -> &[u8] ⓘ
Coerce into the slice of initialized memory which is present.
Sourcepub fn as_mut_slice(&mut self) -> &[u8] ⓘ
pub fn as_mut_slice(&mut self) -> &[u8] ⓘ
Coerce into the mutable slice of initialized memory which is present.
Sourcepub fn extend_from_slice(&mut self, source: &[u8]) -> bool
pub fn extend_from_slice(&mut self, source: &[u8]) -> bool
Try and extend from the given slice.
Sourcepub fn write_bytes<C>(
&mut self,
cx: &mut C,
source: &[u8],
) -> Result<(), <C as Context>::Error>where
C: Context<Input = FixedBytesOverflow>,
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>
impl<const N: usize> Default for FixedBytes<N>
Source§fn default() -> FixedBytes<N>
fn default() -> FixedBytes<N>
Returns the “default value” for a type. Read more
Source§impl<const N: usize> Writer for FixedBytes<N>
impl<const N: usize> Writer for FixedBytes<N>
Source§type Error = FixedBytesOverflow
type Error = FixedBytesOverflow
The error type raised by the writer.
Source§type Mut<'this> = &'this mut FixedBytes<N>
where
FixedBytes<N>: 'this
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<'_>
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>
fn write_buffer<C, B>( &mut self, cx: &mut C, buffer: B, ) -> Result<(), <C as Context>::Error>
Write a buffer to the current writer.
Source§fn write_bytes<C>(
&mut self,
cx: &mut C,
bytes: &[u8],
) -> Result<(), <C as Context>::Error>
fn write_bytes<C>( &mut self, cx: &mut C, bytes: &[u8], ) -> Result<(), <C as Context>::Error>
Write bytes to the current writer.
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> 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