pub struct ClientWatch { /* private fields */ }Expand description
Tracks how long a host has gone without a client.
Pure bookkeeping, with the clock passed in, so the whole rule is testable
without sockets or sleeping. A host calls observe each
pass of its loop with the current client count.
Implementations§
Source§impl ClientWatch
impl ClientWatch
Sourcepub const fn new(timeout: ClientTimeout, now: Instant) -> Self
pub const fn new(timeout: ClientTimeout, now: Instant) -> Self
Starts watching, with the clock already running from now.
Sourcepub const fn ever_connected(&self) -> bool
pub const fn ever_connected(&self) -> bool
Whether any client has connected since the host started.
Sourcepub fn observe(&mut self, clients: usize, now: Instant) -> WatchState
pub fn observe(&mut self, clients: usize, now: Instant) -> WatchState
Records the current client count and says what to do.
now is passed rather than read so the rule can be tested at any point
on the clock without waiting for real time to pass.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ClientWatch
impl RefUnwindSafe for ClientWatch
impl Send for ClientWatch
impl Sync for ClientWatch
impl Unpin for ClientWatch
impl UnsafeUnpin for ClientWatch
impl UnwindSafe for ClientWatch
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