serialplugin_testing/
lib.rs1#![cfg_attr(not(doctest), doc = include_str!("../README.md"))]
3#![warn(missing_docs)]
4mod clock;
11mod fake;
12mod modem;
13pub mod mux;
14pub mod peer;
15
16#[cfg(feature = "tokio")]
17pub use clock::TokioClock;
18pub use clock::{Clock, Job, ManualClock, SystemClock};
19pub use fake::{Call, FakeDevice, FakePort, Faults, Lines};
20pub use modem::{Command, Modem, ModemLog, MuxOptions};
21
22use std::time::{Duration, Instant};
23
24pub const WAIT: Duration = Duration::from_secs(10);
27
28pub fn eventually(what: &str, mut done: impl FnMut() -> bool) {
33 let deadline = Instant::now() + WAIT;
34 while !done() {
35 assert!(Instant::now() < deadline, "never: {what}");
36 std::thread::park_timeout(Duration::from_millis(1));
37 }
38}