Skip to main content

SessionConfig

Struct SessionConfig 

Source
pub struct SessionConfig {
Show 19 fields pub sender_comp_id: CompId, pub target_comp_id: CompId, pub begin_string: String, pub heartbeat_interval: Duration, pub reset_on_logon: bool, pub reset_on_logout: bool, pub reset_on_disconnect: bool, pub max_message_size: usize, pub logon_timeout: Duration, pub logout_timeout: Duration, pub validate_checksum: bool, pub validate_length: bool, pub sending_time_tolerance: Duration, pub resend_timeout: Duration, pub max_resend_requests: u32, pub sender_sub_id: Option<String>, pub target_sub_id: Option<String>, pub sender_location_id: Option<String>, pub target_location_id: Option<String>,
}
Expand description

Configuration for a FIX session.

Construct one with SessionConfigBuilder, which validates every knob. The fields are public so a configuration can also be assembled or adjusted directly; SessionConfig::validate then says whether the result is usable, and ironfix-engine calls it before dialling.

Fields§

§sender_comp_id: CompId

Sender CompID (tag 49).

§target_comp_id: CompId

Target CompID (tag 56).

§begin_string: String

FIX version BeginString, tag 8 (e.g. FIX.4.4).

1..=MAX_ID_LEN bytes of printable ASCII except =. Whether the version can actually be framed is a separate question, answered by ironfix-engine.

§heartbeat_interval: Duration

Heartbeat interval, HeartBtInt (108).

Whole seconds, from MIN_HEARTBEAT_INTERVAL_SECS to MAX_HEARTBEAT_INTERVAL_SECS. Duration::ZERO is the legal HeartBtInt = 0 case and disables heartbeating entirely.

§reset_on_logon: bool

Whether to set ResetSeqNumFlag (141) on the outbound Logon.

§reset_on_logout: bool

Whether to reset sequence numbers after a graceful Logout.

§reset_on_disconnect: bool

Whether to reset sequence numbers when the session disconnects.

§max_message_size: usize

Maximum accepted message size, in bytes.

From MIN_MESSAGE_SIZE_LIMIT to MAX_MESSAGE_SIZE_LIMIT. Also the per-connection buffering ceiling of the codec.

§logon_timeout: Duration

How long to wait for the Logon acknowledgement.

Non-zero, at most MAX_TIMEOUT.

§logout_timeout: Duration

How long to wait for the Logout acknowledgement.

Non-zero, at most MAX_TIMEOUT.

§validate_checksum: bool

Whether to validate the CheckSum (10) of inbound messages.

§validate_length: bool

Whether to validate incoming message length.

§sending_time_tolerance: Duration

Largest difference tolerated, in either direction, between an inbound message’s SendingTime (52) and the local clock.

Units: wall-clock duration. Range: any duration; Duration::ZERO disables SendingTime validation entirely, including the presence and format checks. Default: 120 seconds.

The default matches the tolerance FIX engines have converged on (QuickFIX’s MaxLatency) and is the interval it is worth choosing: a host synchronised by NTP stays within milliseconds of true time, so two minutes is orders of magnitude more slack than a healthy peer ever needs, while a host that is not synchronised at all drifts past two minutes within days. Anything much tighter starts rejecting sessions over ordinary drift and queueing latency; anything much looser stops distinguishing a wrong clock from a right one.

§resend_timeout: Duration

How long an outstanding ResendRequest (2) may make no progress before it is retried, and eventually abandoned.

Units: wall-clock duration, measured from the moment the request was sent and restarted by every request that follows it. Any in-sequence message clears the outstanding request altogether, so this measures a gap that is not being filled at all, not a slow replay. Range: any duration; a value below the engine’s 100 ms reactor tick simply retries on the next tick. Default: 10 seconds.

§max_resend_requests: u32

Maximum number of ResendRequest (2) messages sent for one gap, counting the first.

Once they are spent the session is ended with a Logout rather than left waiting for a peer that is not answering. Range: 1 and above; 0 is read as 1, because the first request is unconditional. Default: 3, which with the default SessionConfig::resend_timeout bounds an unrecoverable gap at 30 seconds plus the logout handshake.

Read it through SessionConfig::resend_attempt_limit, which applies the lower bound.

§sender_sub_id: Option<String>

Optional sender sub ID (tag 50), 1..=MAX_ID_LEN bytes when set.

§target_sub_id: Option<String>

Optional target sub ID (tag 57), 1..=MAX_ID_LEN bytes when set.

§sender_location_id: Option<String>

Optional sender location ID (tag 142), 1..=MAX_ID_LEN bytes when set.

§target_location_id: Option<String>

Optional target location ID (tag 143), 1..=MAX_ID_LEN bytes when set.

Implementations§

Source§

impl SessionConfig

Source

pub fn new( sender_comp_id: CompId, target_comp_id: CompId, begin_string: impl Into<String>, ) -> SessionConfig

Creates a session configuration with the documented defaults: a 30 s heartbeat, 10 s handshake timeouts, a 1 MiB message limit, checksum and length validation on, and no sequence resets.

This applies defaults; it does not validate. begin_string is the one argument that can be malformed — call SessionConfig::validate, or build through SessionConfigBuilder, to find out before the session dials.

§Arguments
  • sender_comp_id - The sender CompID (tag 49)
  • target_comp_id - The target CompID (tag 56)
  • begin_string - The BeginString (tag 8), e.g. FIX.4.4
Source

pub fn validate(&self) -> Result<(), SessionConfigError>

Checks every knob against the ranges documented on the module.

The CompIDs are not re-checked: CompId validates its charset and length at construction, so an illegal one is unrepresentable.

Duration::ZERO passes as a heartbeat interval — it is the legal HeartBtInt = 0. Only SessionConfigBuilder requires that case to be opted into by name.

§Errors

Returns the first SessionConfigError found: an empty, oversized or non-encodable identity string, a fractional or out-of-range heartbeat interval, a zero or excessive handshake timeout, or a message-size limit outside MIN_MESSAGE_SIZE_LIMIT..=MAX_MESSAGE_SIZE_LIMIT.

Source

pub const fn with_heartbeat_interval(self, interval: Duration) -> SessionConfig

Sets the heartbeat interval, HeartBtInt (108).

Whole seconds, MIN_HEARTBEAT_INTERVAL_SECS..=MAX_HEARTBEAT_INTERVAL_SECS, or Duration::ZERO to disable heartbeating. Checked by SessionConfig::validate, not here.

Source

pub const fn with_reset_on_logon(self, reset: bool) -> SessionConfig

Sets whether the outbound Logon carries ResetSeqNumFlag (141) = Y.

Source

pub const fn with_max_message_size(self, size: usize) -> SessionConfig

Sets the maximum accepted message size, in bytes.

MIN_MESSAGE_SIZE_LIMIT..=MAX_MESSAGE_SIZE_LIMIT. Checked by SessionConfig::validate, not here.

Source

pub const fn with_logon_timeout(self, timeout: Duration) -> SessionConfig

Sets how long to wait for the Logon acknowledgement.

Non-zero, at most MAX_TIMEOUT. Checked by SessionConfig::validate, not here.

Source

pub fn with_sender_sub_id(self, sub_id: impl Into<String>) -> SessionConfig

Sets the sender sub ID (tag 50).

1..=MAX_ID_LEN bytes of printable ASCII except =. Checked by SessionConfig::validate, not here.

Source

pub fn with_target_sub_id(self, sub_id: impl Into<String>) -> SessionConfig

Sets the target sub ID (tag 57).

1..=MAX_ID_LEN bytes of printable ASCII except =. Checked by SessionConfig::validate, not here.

Source

pub fn with_logout_timeout(self, timeout: Duration) -> SessionConfig

Sets the logout timeout.

Source

pub fn with_sending_time_tolerance(self, tolerance: Duration) -> SessionConfig

Sets the tolerance applied to an inbound SendingTime (52).

Duration::ZERO disables SendingTime validation. See SessionConfig::sending_time_tolerance for the default and its rationale.

Source

pub fn with_resend_timeout(self, timeout: Duration) -> SessionConfig

Sets how long an outstanding ResendRequest (2) may make no progress before it is retried.

Source

pub const fn with_max_resend_requests(self, attempts: u32) -> SessionConfig

Sets how many ResendRequest (2) messages may be sent for one gap, counting the first. A value of 0 is read as 1.

Source

pub const fn heartbeat_interval_secs(&self) -> u64

Returns the heartbeat interval as the whole seconds that go into HeartBtInt (108).

Exact for any configuration that passed SessionConfig::validate, which is what rules out a fractional interval; on an unvalidated configuration a sub-second interval would floor to 0, which on the wire means “do not heartbeat”.

Source

pub const fn resend_attempt_limit(&self) -> u32

Returns how many ResendRequest (2) messages may be sent for one gap, never less than the one that opens the recovery.

Trait Implementations§

Source§

impl Clone for SessionConfig

Source§

fn clone(&self) -> SessionConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SessionConfig

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more