19 lines
378 B
Rust
19 lines
378 B
Rust
|
use smoltcp::time::{Duration, Instant};
|
||
|
use core::cell::Cell;
|
||
|
|
||
|
#[derive(Debug)]
|
||
|
pub struct Clock(Cell<Instant>);
|
||
|
|
||
|
impl Clock {
|
||
|
pub fn new() -> Clock {
|
||
|
Clock(Cell::new(Instant::from_millis(0)))
|
||
|
}
|
||
|
|
||
|
pub fn advance(&self, duration: Duration) {
|
||
|
self.0.set(self.0.get() + duration)
|
||
|
}
|
||
|
|
||
|
pub fn elapsed(&self) -> Instant {
|
||
|
self.0.get()
|
||
|
}
|
||
|
}
|