pub struct Tracked {
pub reference: u32,
pub wraps: u8,
}Expand description
One counter, and what is known about how often it has rolled over.
Fields§
§reference: u32The last value read, in microseconds.
wraps: u8How many times it has been seen to roll over, kept to five bits.
Implementations§
Source§impl Tracked
impl Tracked
Sourcepub const fn advance(&mut self, now: u32)
pub const fn advance(&mut self, now: u32)
Takes a new reading, noticing a rollover.
§Arguments
now- the value just read, in microseconds.
§Examples
use pamoja_radios::sx1302::timestamp::Tracked;
let mut counter = Tracked::default();
counter.advance(1_000);
assert_eq!(counter.wraps, 0);
// A reading below the last one can only mean it went round.
counter.advance(5);
assert_eq!(counter.wraps, 1);Sourcepub const fn widened(&self) -> u32
pub const fn widened(&self) -> u32
The last reading, widened past the rollover.
§Returns
The value in microseconds, counting every rollover so far.
§Examples
use pamoja_radios::sx1302::timestamp::Tracked;
let mut counter = Tracked::default();
counter.advance(1_000);
counter.advance(5);
// One rollover, so the reading sits a whole counter above where it reads.
assert_eq!(counter.widened(), (1 << 27) | 5);Trait Implementations§
impl Copy for Tracked
impl Eq for Tracked
impl StructuralPartialEq for Tracked
Auto Trait Implementations§
impl Freeze for Tracked
impl RefUnwindSafe for Tracked
impl Send for Tracked
impl Sync for Tracked
impl Unpin for Tracked
impl UnsafeUnpin for Tracked
impl UnwindSafe for Tracked
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
Mutably borrows from an owned value. Read more