embedded-nano-mesh 2.1.11

Lightweight mesh communication protocol for embedded devices
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use super::super::Packet;

/// Case, when packet lifetime ended, and the packet can no longer
/// be sent further.
pub struct PacketLifetimeEnded;

impl Packet {
    pub fn deacrease_lifetime(mut self) -> Result<Self, PacketLifetimeEnded> {
        match self.lifetime.cmp(&1) {
            core::cmp::Ordering::Greater => {
                self.lifetime -= 1;
                Ok(self)
            }
            _ => Err(PacketLifetimeEnded),
        }
    }
}