Skip to main content

ExposedEncodedArray

Struct ExposedEncodedArray 

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

Owned stack array extracted from EncodedBuffer.

This wrapper keeps the extracted encoded bytes on the crate’s best-effort drop-time cleanup path. Use Self::into_exposed_unprotected_array_caller_must_zeroize only when a bare array is unavoidable and the caller will handle cleanup.

Implementations§

Source§

impl<const CAP: usize> ExposedEncodedArray<CAP>

Source

pub const fn from_array(bytes: [u8; CAP], len: usize) -> Self

Wraps an encoded backing array and visible length.

§Panics

Panics if len is greater than CAP.

Source

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

Returns the visible encoded bytes.

Source

pub const fn len(&self) -> usize

Returns the number of visible encoded bytes.

Source

pub const fn is_empty(&self) -> bool

Returns whether there are no visible encoded bytes.

Source

pub const fn capacity(&self) -> usize

Returns the backing array capacity.

Source

pub fn into_exposed_unprotected_array_caller_must_zeroize( self, ) -> ([u8; CAP], usize)

Consumes the wrapper and returns a bare array plus visible length.

This is an unprotected escape hatch. The returned array will not be cleared by this crate on drop. Callers must clear it with their own approved zeroization policy.

§Security

Treat this as a cleanup-boundary API. Failing to clear the returned array leaves the encoded bytes in ordinary caller-owned memory until overwritten by later stack or heap activity.

Trait Implementations§

Source§

impl<const CAP: usize> Debug for ExposedEncodedArray<CAP>

Source§

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

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

impl<const CAP: usize> Drop for ExposedEncodedArray<CAP>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<const CAP: usize> Freeze for ExposedEncodedArray<CAP>

§

impl<const CAP: usize> RefUnwindSafe for ExposedEncodedArray<CAP>

§

impl<const CAP: usize> Send for ExposedEncodedArray<CAP>

§

impl<const CAP: usize> Sync for ExposedEncodedArray<CAP>

§

impl<const CAP: usize> Unpin for ExposedEncodedArray<CAP>

§

impl<const CAP: usize> UnsafeUnpin for ExposedEncodedArray<CAP>

§

impl<const CAP: usize> UnwindSafe for ExposedEncodedArray<CAP>

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.