Struct riot_coap_handler_demos::ping::PingPool

source ·
pub struct PingPool {
    jobs: [TryLock<Option<PingJob>>; 4],
    next_id: TryLock<u16>,
}
Available on crate feature ping only.
Expand description

Container for a number of ping jobs

To make this run, the pool’s tick method needs to be called at regular intervals (at least while its any_active_now returns true), and any incoming ICMP responses need to be turned over to its .received method.

Instead of calling [.tick()] and [.received()] manually, the [.run_on_async()] infinite async function can be run.

In parallel to that, the PingPool needs to be registered with a CoAP handler (see ping_tree).

Fields§

§jobs: [TryLock<Option<PingJob>>; 4]§next_id: TryLock<u16>

Implementations§

source§

impl PingPool

source

pub const fn new() -> Self

source

pub fn register( self: &'static PingPool, callback_slot: &'static mut Slot<PingCallback>, )

Set up a hook for receiving ICMP messages.

It requires a ’static pool to ease GNRC registrations, and GNRC callback slot that contains the memory needed for handling the registration. Note that the slot can be crated through a static_cell::StaticCell initialized with SLOT.init(Default::default()), and by its own construction is previously unused. (The static mutable reference is consumed in this function).

source

pub async fn tick_on_async(self: &PingPool, delay: impl DelayNs)

Periodically send a tick to self, keeping all the sending and expiration activities active.

§Caveats

Currently, this has no means of pausing the tick timer while no pings are pending. This makes it not really a suitable replacement for the deprecated [.any_active_now()] function, but it can gain that capability once it is added.

source

pub fn tick(&self)

source

pub fn received(&self, packet: Pktsnip<Shared>)

source

pub fn any_active_now(&self) -> bool

👎Deprecated: Use tick_on_async: any_active_now only allows you to retire the timer if you can get an ask-again signal from the network stack at any time something happens around the CoAP handler. (Otherwise, how would you know when to resume ticking?)

Trait Implementations§

source§

impl Debug for PingPool

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for PingPool

source§

fn default() -> PingPool

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

Auto Trait Implementations§

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> IntoSwitch for T

source§

fn into_switch<ActiveLevel>(self) -> Switch<T, ActiveLevel>

Consumes the IoPin returning a Switch of the appropriate ActiveLevel. Read more
source§

fn into_active_low_switch(self) -> Switch<Self, ActiveLow>
where Self: Sized,

Consumes the IoPin returning a Switch<IoPin, ActiveLow>. Read more
source§

fn into_active_high_switch(self) -> Switch<Self, ActiveHigh>
where Self: Sized,

Consumes the IoPin returning a Switch<IoPin, ActiveHigh>. Read more
source§

impl<T> Same for T

source§

type Output = T

Should always be Self
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.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 148 bytes