Skip to main content

Stack

Struct Stack 

Source
pub struct Stack { /* private fields */ }
Expand description

Single heap allocation, aligned to 16 bytes, with a 64-byte painted lower guard. This detects damage at boundaries; it does not provide memory protection.

Implementations§

Source§

impl Stack

Source

pub fn new(size: usize) -> Self

Allocate a stack with at least DEFAULT_MIN_STACK_SIZE (4 KiB) usable bytes, rounded up to 16 bytes, plus a 64-byte painted lower guard.

Source

pub fn with_min_size(size: usize, min_usable: usize) -> Self

Allocate a stack with a caller-chosen minimum usable size, floored at MIN_STACK_SIZE (2 KiB), rounded up to 16 bytes, plus the same 64-byte painted lower guard as Stack::new.

Lowering the minimum below 4 KiB saves RAM on constrained MCUs (e.g. 256 KiB SRAM), at the cost of tighter headroom for call depth, debug frames, suspended futures pinned on the native stack, and shared interrupt frames. Audit worst-case stack usage before choosing a 2 KiB stack.

Source

pub fn try_with_min_size(size: usize, min_usable: usize) -> Option<Self>

Like Stack::with_min_size, but returns None instead of panicking or aborting when the size is unrepresentable or the allocator is out of memory.

Source

pub fn usable_size(&self) -> usize

Source

pub fn guard_intact(&self) -> bool

Trait Implementations§

Source§

impl Drop for Stack

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 Freeze for Stack

§

impl RefUnwindSafe for Stack

§

impl !Send for Stack

§

impl !Sync for Stack

§

impl Unpin for Stack

§

impl UnsafeUnpin for Stack

§

impl UnwindSafe for Stack

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.