Skip to main content

FixedBuf

Struct FixedBuf 

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

Stack-backed fixed-capacity buffer with 8-byte alignment.

FixedBuf<N> provides N bytes of inline storage with no heap allocation, enabling nearest regions in no_std environments or on the stack.

§Panics

reserve and resize panic if the requested size exceeds N.

Implementations§

Source§

impl<const N: usize> FixedBuf<N>

Source

pub const fn new() -> Self

Create an empty fixed buffer.

This is const, enabling static regions.

Trait Implementations§

Source§

impl<const N: usize> Buf for FixedBuf<N>

Source§

const ALIGN: usize = 8

Buffer alignment guarantee.
Source§

fn empty() -> Self

Create an empty buffer (len = 0).
Source§

fn as_ptr(&self) -> *const u8

Raw pointer to the buffer start.
Source§

fn as_mut_ptr(&mut self) -> *mut u8

Mutable raw pointer to the buffer start.
Source§

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

View the buffer contents as a byte slice.
Source§

fn len(&self) -> u32

Current byte length.
Source§

fn capacity(&self) -> u32

Current capacity in bytes.
Source§

fn resize(&mut self, new_len: u32, fill: u8)

Grow or shrink the buffer, filling new bytes with fill.
Source§

fn reserve(&mut self, additional: u32)

Ensure at least additional bytes of spare capacity.
Source§

fn extend_from_slice(&mut self, data: &[u8])

Append bytes from a slice.
Source§

fn is_empty(&self) -> bool

Returns true if the buffer contains no bytes.
Source§

fn align_to(&mut self, align: usize)

Pad len up to the next multiple of align.
Source§

fn alloc<U: Flat>(&mut self) -> Pos

Align + allocate space for one U, return its position. Read more
Source§

fn expose_provenance(&self)

Expose provenance so Near::get can recover it via with_exposed_provenance.
Source§

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

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

Source§

fn default() -> Self

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

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

Source§

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

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

impl<const N: usize> UnwindSafe for FixedBuf<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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.