pub struct LinkController { /* private fields */ }Expand description
Drives link state transitions based on ep0 lifecycle events, heartbeat pings, endpoint I/O errors, and periodic liveness ticks.
This controller is intentionally small and side-effect-free: it only tracks state and emits commands. The caller is responsible for actually opening/closing endpoints and replaying or parking I/O.
Implementations§
Source§impl LinkController
impl LinkController
Sourcepub fn new(liveness_timeout: Duration) -> Self
pub fn new(liveness_timeout: Duration) -> Self
Construct a new controller with a configurable liveness timeout.
Sourcepub fn last_offline_reason(&self) -> Option<LinkOfflineReason>
pub fn last_offline_reason(&self) -> Option<LinkOfflineReason>
Most recent reason the link moved Offline.
Sourcepub fn on_ep0_event(&mut self, event: Event<'_>)
pub fn on_ep0_event(&mut self, event: Event<'_>)
Notify the controller of an ep0 lifecycle event.
Sourcepub fn on_status_ping(&mut self)
pub fn on_status_ping(&mut self)
Notify the controller that a SMOO_STATUS (or equivalent heartbeat) was seen.
Sourcepub fn on_io_error(&mut self, _err: &Error)
pub fn on_io_error(&mut self, _err: &Error)
Notify the controller that an endpoint I/O error occurred.
Sourcepub fn tick(&mut self, now: Instant)
pub fn tick(&mut self, now: Instant)
Advance the controller based on the current time to detect liveness timeouts.
Sourcepub fn take_command(&mut self) -> Option<LinkCommand>
pub fn take_command(&mut self) -> Option<LinkCommand>
Drain the next pending command, if any.
Auto Trait Implementations§
impl Freeze for LinkController
impl RefUnwindSafe for LinkController
impl Send for LinkController
impl Sync for LinkController
impl Unpin for LinkController
impl UnsafeUnpin for LinkController
impl UnwindSafe for LinkController
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