Skip to main content

UninitStackBuffer

Struct UninitStackBuffer 

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

Memory-efficient uninitialized stack buffer

This buffer uses MaybeUninit to avoid zeroing memory that will be immediately overwritten, providing better performance for large buffers.

Implementations§

Source§

impl<const N: usize> UninitStackBuffer<N>

Source

pub fn new() -> Self

Create a new uninitialized stack buffer

Source

pub fn capacity(&self) -> usize

Get the maximum capacity of the buffer

Source

pub fn len(&self) -> usize

Get the number of bytes currently used

Source

pub fn is_empty(&self) -> bool

Check if the buffer is empty

Source

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

Get the used portion as a slice

Source

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

Get the used portion as a mutable slice

Source

pub fn resize(&mut self, new_len: usize) -> Result<(), &'static str>

Resize the buffer to the specified length

Source

pub fn clear(&mut self)

Clear the buffer

Source

pub fn append(&mut self, data: &[u8]) -> Result<(), &'static str>

Append data to the buffer

Trait Implementations§

Source§

impl<const N: usize> Debug for UninitStackBuffer<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 UninitStackBuffer<N>

Source§

fn default() -> Self

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

impl<const N: usize> Drop for UninitStackBuffer<N>

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 N: usize> Freeze for UninitStackBuffer<N>

§

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

§

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

§

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

§

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

§

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

§

impl<const N: usize> UnwindSafe for UninitStackBuffer<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> Same for T

Source§

type Output = T

Should always be Self
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<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more