xarxa

Crates

git

Versions

default

Flavors

Skip to main content

StaticPool

Struct StaticPool 

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

Statically allocated Pool.

Pick SIZE for the largest frame your links carry:

  • 1514 for Ethernet. 1518 or 1522 with one or two VLAN tags.
  • 9018 or so for Ethernet with jumbo frames.
  • 128 or 256 for IEEE 802.15.4 without 6LoWPAN fragmentation. 256 leaves room for the headers to grow when they are decompressed.

Add the largest tx_headroom of your drivers. A frame and the headroom in front of it share one buffer.

SIZE also caps the MTU of every interface. Going below the protocol minimums works, but breaks interoperability:

  • IPv6 needs 1280 bytes plus the link header (RFC 8200).
  • IPv4 hosts must accept 576 bytes plus the link header (RFC 791).

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

Put it in a static:

use xarxa::{Stack, StaticPool};

static POOL: StaticPool<1514, 16> = StaticPool::new();

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

The pool is zero-initialized, so a static of it lives in .bss. To put it in DMA-capable memory, give the static a #[link_section]. That memory must then be zeroed before the pool is used.

Implementations§

Source§

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

Source

pub const fn new() -> Self

Create a pool, with every buffer free.

Trait Implementations§

Source§

impl<const SIZE: usize, const COUNT: usize, const ALIGN: usize> Default for StaticPool<SIZE, COUNT, ALIGN>
where Align<ALIGN>: ValidAlign,

Source§

fn default() -> Self

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

impl<const SIZE: usize, const COUNT: usize, const ALIGN: usize> Pool for StaticPool<SIZE, COUNT, 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.
Source§

impl<const SIZE: usize, const COUNT: usize, const ALIGN: usize> Sync for StaticPool<SIZE, COUNT, ALIGN>
where Align<ALIGN>: ValidAlign,

Auto Trait Implementations§

§

impl<const SIZE: usize = 1514, const COUNT: usize = 16, const ALIGN: usize = 1> !Freeze for StaticPool<SIZE, COUNT, ALIGN>

§

impl<const SIZE: usize = 1514, const COUNT: usize = 16, const ALIGN: usize = 1> !RefUnwindSafe for StaticPool<SIZE, COUNT, ALIGN>

§

impl<const SIZE: usize = 1514, const COUNT: usize = 16, const ALIGN: usize = 1> !Send for StaticPool<SIZE, COUNT, ALIGN>

§

impl<const SIZE: usize = 1514, const COUNT: usize = 16, const ALIGN: usize = 1> !Unpin for StaticPool<SIZE, COUNT, ALIGN>

§

impl<const SIZE: usize = 1514, const COUNT: usize = 16, const ALIGN: usize = 1> !UnsafeUnpin for StaticPool<SIZE, COUNT, ALIGN>

§

impl<const SIZE: usize = 1514, const COUNT: usize = 16, const ALIGN: usize = 1> !UnwindSafe for StaticPool<SIZE, COUNT, 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.