pub struct ConnectionMonitor { /* private fields */ }Expand description
Connection monitor
Monitors backend connection state and optionally handles automatic reconnection. By default, auto-reconnect is disabled.
§Example
ⓘ
use canlink_hal::monitor::{ConnectionMonitor, ConnectionState};
use std::time::Duration;
let monitor = ConnectionMonitor::new(Duration::from_secs(1));Implementations§
Source§impl ConnectionMonitor
impl ConnectionMonitor
Sourcepub fn from_config(config: &MonitorConfig) -> Self
pub fn from_config(config: &MonitorConfig) -> Self
Create a ConnectionMonitor from configuration
Source§impl ConnectionMonitor
impl ConnectionMonitor
Sourcepub fn new(heartbeat_interval: Duration) -> Self
pub fn new(heartbeat_interval: Duration) -> Self
Create a new connection monitor without auto-reconnect
§Arguments
heartbeat_interval- Interval between heartbeat checks
Sourcepub fn with_reconnect(
heartbeat_interval: Duration,
reconnect_config: ReconnectConfig,
) -> Self
pub fn with_reconnect( heartbeat_interval: Duration, reconnect_config: ReconnectConfig, ) -> Self
Create a connection monitor with auto-reconnect enabled
§Arguments
heartbeat_interval- Interval between heartbeat checksreconnect_config- Reconnection configuration
Sourcepub fn state(&self) -> ConnectionState
pub fn state(&self) -> ConnectionState
Get the current connection state
Sourcepub fn heartbeat_interval(&self) -> Duration
pub fn heartbeat_interval(&self) -> Duration
Get the heartbeat interval
Sourcepub fn auto_reconnect_enabled(&self) -> bool
pub fn auto_reconnect_enabled(&self) -> bool
Check if auto-reconnect is enabled
Sourcepub fn reconnect_config(&self) -> Option<&ReconnectConfig>
pub fn reconnect_config(&self) -> Option<&ReconnectConfig>
Get the reconnect configuration
Sourcepub fn set_state(&mut self, state: ConnectionState)
pub fn set_state(&mut self, state: ConnectionState)
Set the connection state (for testing/manual control)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ConnectionMonitor
impl RefUnwindSafe for ConnectionMonitor
impl Send for ConnectionMonitor
impl Sync for ConnectionMonitor
impl Unpin for ConnectionMonitor
impl UnsafeUnpin for ConnectionMonitor
impl UnwindSafe for ConnectionMonitor
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