diff --git a/examples/util/clock.rs b/examples/util/clock.rs new file mode 100644 index 0000000..8064950 --- /dev/null +++ b/examples/util/clock.rs @@ -0,0 +1,19 @@ +use smoltcp::time::{Duration, Instant}; +use core::cell::Cell; + +#[derive(Debug)] +pub struct Clock(Cell); + +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() + } +} \ No newline at end of file