pub struct HeartbeatManager { /* private fields */ }Expand description
Manages heartbeat timing for a FIX session.
Implementations§
Source§impl HeartbeatManager
impl HeartbeatManager
Sourcepub fn new(interval: Duration) -> HeartbeatManager
pub fn new(interval: Duration) -> HeartbeatManager
Creates a new heartbeat manager with the specified interval.
§Arguments
interval- The heartbeat interval
Sourcepub fn on_message_sent(&mut self)
pub fn on_message_sent(&mut self)
Records that a message was sent.
Sourcepub fn on_message_received(
&mut self,
is_heartbeat: bool,
test_req_id: Option<&str>,
)
pub fn on_message_received( &mut self, is_heartbeat: bool, test_req_id: Option<&str>, )
Records that a message was received.
If a TestRequest was pending and a Heartbeat with matching ID is received, the pending request is cleared.
§Arguments
is_heartbeat- Whether the received message is a Heartbeattest_req_id- The TestReqID from the Heartbeat, if present
Sourcepub fn should_send_heartbeat(&self) -> bool
pub fn should_send_heartbeat(&self) -> bool
Checks if a heartbeat should be sent.
A heartbeat should be sent if no message has been sent within the interval.
Sourcepub fn should_send_test_request(&self) -> bool
pub fn should_send_test_request(&self) -> bool
Checks if a TestRequest should be sent.
A TestRequest should be sent if no message has been received within the interval plus a grace period, and no TestRequest is already pending.
Sourcepub fn is_timed_out(&self) -> bool
pub fn is_timed_out(&self) -> bool
Checks if the session has timed out.
A timeout occurs if a TestRequest was sent but no response was received within the interval.
Sourcepub fn on_test_request_sent(&mut self, test_req_id: String)
pub fn on_test_request_sent(&mut self, test_req_id: String)
Sourcepub fn pending_test_request(&self) -> Option<&str>
pub fn pending_test_request(&self) -> Option<&str>
Returns the pending TestRequest ID, if any.
Sourcepub fn time_since_last_received(&self) -> Duration
pub fn time_since_last_received(&self) -> Duration
Returns the time since the last message was received.
Sourcepub fn time_since_last_sent(&self) -> Duration
pub fn time_since_last_sent(&self) -> Duration
Returns the time since the last message was sent.