Skip to main content

HeartbeatManager

Struct HeartbeatManager 

Source
pub struct HeartbeatManager { /* private fields */ }
Expand description

Manages heartbeat timing for a FIX session.

Implementations§

Source§

impl HeartbeatManager

Source

pub fn new(interval: Duration) -> HeartbeatManager

Creates a new heartbeat manager with the specified interval.

§Arguments
  • interval - The heartbeat interval
Source

pub fn on_message_sent(&mut self)

Records that a message was sent.

Source

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 Heartbeat
  • test_req_id - The TestReqID from the Heartbeat, if present
Source

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.

Source

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.

Source

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.

Source

pub fn on_test_request_sent(&mut self, test_req_id: String)

Records that a TestRequest was sent.

§Arguments
  • test_req_id - The TestReqID that was sent
Source

pub fn pending_test_request(&self) -> Option<&str>

Returns the pending TestRequest ID, if any.

Source

pub fn time_since_last_received(&self) -> Duration

Returns the time since the last message was received.

Source

pub fn time_since_last_sent(&self) -> Duration

Returns the time since the last message was sent.

Source

pub const fn interval(&self) -> Duration

Returns the heartbeat interval.

Source

pub fn reset(&mut self)

Resets the manager state.

Trait Implementations§

Source§

impl Debug for HeartbeatManager

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.