xarxa

Crates

git

Versions

default

Flavors

Skip to main content

AllocPool

Struct AllocPool 

Source
pub struct AllocPool<const SIZE: usize = 1514, const ALIGN: usize = 1>
where Align<ALIGN>: ValidAlign,
{ /* private fields */ }
Expand description

A Pool that allocates each buffer from the heap.

At most max_count buffers are allocated at a time. If the heap runs out before that, the allocation aborts, like any other heap allocation. Make sure the heap has room for max_count buffers.

StaticPool explains how to pick SIZE.

ALIGN can be 1, 2, 4, 8, 16, 32 or 64.

The build fails for the same buffer sizes that fail with StaticPool.

It must be 'static. It can go in a static:

use xarxa::{AllocPool, Stack};

static POOL: AllocPool<1514> = AllocPool::new(64);

let stack = Stack::new(&POOL, 0x1234_5678);

Implementations§

Source§

impl<const SIZE: usize, const ALIGN: usize> AllocPool<SIZE, ALIGN>
where Align<ALIGN>: ValidAlign,

Source

pub const fn new(max_count: usize) -> Self

Create a pool that allocates at most max_count buffers at a time.

Trait Implementations§

Source§

impl<const SIZE: usize, const ALIGN: usize> Pool for AllocPool<SIZE, ALIGN>
where Align<ALIGN>: ValidAlign,

Source§

fn alloc(&'static self) -> Option<PacketBuf>

Allocate a buffer. Read more
Source§

fn buf_capacity(&self) -> usize

Size of the storage of each buffer, in bytes.

Auto Trait Implementations§

§

impl<const SIZE: usize = 1514, const ALIGN: usize = 1> !Freeze for AllocPool<SIZE, ALIGN>

§

impl<const SIZE: usize, const ALIGN: usize> RefUnwindSafe for AllocPool<SIZE, ALIGN>

§

impl<const SIZE: usize, const ALIGN: usize> Send for AllocPool<SIZE, ALIGN>

§

impl<const SIZE: usize, const ALIGN: usize> Sync for AllocPool<SIZE, ALIGN>

§

impl<const SIZE: usize, const ALIGN: usize> Unpin for AllocPool<SIZE, ALIGN>

§

impl<const SIZE: usize, const ALIGN: usize> UnsafeUnpin for AllocPool<SIZE, ALIGN>

§

impl<const SIZE: usize, const ALIGN: usize> UnwindSafe for AllocPool<SIZE, ALIGN>

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 = !

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.