trouble-host

Crates

git

Versions

default

Flavors

Trait PacketPool

Source
pub trait PacketPool: 'static {
    type Packet: Packet;

    const MTU: usize;

    // Required methods
    fn allocate() -> Option<Self::Packet>;
    fn capacity() -> usize;
}
Expand description

A Packet Pool that can allocate packets of the desired size.

The MTU is usually related to the MTU of l2cap payloads.

Required Associated Constants§

Source

const MTU: usize

The maximum size a packet can have.

Required Associated Types§

Source

type Packet: Packet

Packet type provided by this pool.

Required Methods§

Source

fn allocate() -> Option<Self::Packet>

Allocate a new buffer with space for MTU bytes. Return None when the allocation can’t be fulfilled.

This function is called by the L2CAP driver when it needs space to receive a packet into. It will later call from_raw_parts with the buffer and the amount of bytes it has received.

Source

fn capacity() -> usize

Capacity of this pool in the number of packets.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl PacketPool for DefaultPacketPool

Source§

const MTU: usize = 251usize

Source§

type Packet = DefaultPacket