pub struct PingPool {
jobs: [TryLock<Option<PingJob>>; 4],
next_id: TryLock<u16>,
}
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
impl PingPool
pub const fn new() -> Self
Sourcepub fn register(
self: &'static PingPool,
callback_slot: &'static mut Slot<PingCallback>,
)
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).
Sourcepub async fn tick_on_async(self: &PingPool, delay: impl DelayNs)
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.
pub fn tick(&self)
pub fn received(&self, packet: Pktsnip<Shared>)
pub fn any_active_now(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for PingPool
impl !RefUnwindSafe for PingPool
impl Send for PingPool
impl Sync for PingPool
impl Unpin for PingPool
impl UnwindSafe for PingPool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoSwitch for T
impl<T> IntoSwitch for T
Source§fn into_switch<ActiveLevel>(self) -> Switch<T, ActiveLevel>
fn into_switch<ActiveLevel>(self) -> Switch<T, ActiveLevel>
Source§fn into_active_high_switch(self) -> Switch<Self, ActiveHigh>where
Self: Sized,
fn into_active_high_switch(self) -> Switch<Self, ActiveHigh>where
Self: Sized,
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