pub struct SessionConfigBuilder { /* private fields */ }Expand description
Builder for SessionConfig — the canonical way to configure a session.
Every knob has a setter here, and SessionConfigBuilder::build validates
all of them together. The sender and target CompIDs have no default and
must be set; everything else falls back to the defaults documented on
SessionConfig::new.
§Example
use ironfix_core::types::CompId;
use ironfix_session::config::SessionConfigBuilder;
use std::time::Duration;
let config = SessionConfigBuilder::new()
.sender_comp_id(CompId::new("CLIENT")?)
.target_comp_id(CompId::new("VENUE")?)
.begin_string("FIX.4.4")
.heartbeat_interval(Duration::from_secs(30))
.sender_sub_id("DESK")
.build()?;
assert_eq!(config.heartbeat_interval_secs(), 30);Implementations§
Source§impl SessionConfigBuilder
impl SessionConfigBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a builder holding the defaults documented on
SessionConfig::new.
Sourcepub fn sender_comp_id(self, id: CompId) -> Self
pub fn sender_comp_id(self, id: CompId) -> Self
Sets the sender CompID (tag 49). Required.
Sourcepub fn target_comp_id(self, id: CompId) -> Self
pub fn target_comp_id(self, id: CompId) -> Self
Sets the target CompID (tag 56). Required.
Sourcepub fn begin_string(self, version: impl Into<String>) -> Self
pub fn begin_string(self, version: impl Into<String>) -> Self
Sets the BeginString (tag 8), e.g. FIX.4.4.
1..=MAX_ID_LEN bytes of printable ASCII except =.
Sourcepub const fn heartbeat_interval(self, interval: Duration) -> Self
pub const fn heartbeat_interval(self, interval: Duration) -> Self
Sets the heartbeat interval, HeartBtInt (108).
Whole seconds, from MIN_HEARTBEAT_INTERVAL_SECS to
MAX_HEARTBEAT_INTERVAL_SECS. A fractional or out-of-range value is
refused by SessionConfigBuilder::build; Duration::ZERO is
refused there too, because disabling heartbeats is
SessionConfigBuilder::disable_heartbeats.
Sourcepub const fn disable_heartbeats(self) -> Self
pub const fn disable_heartbeats(self) -> Self
Configures HeartBtInt (108) = 0: no Heartbeats, no TestRequests, and
no heartbeat-driven liveness check for the life of the session.
This is legal FIX and sometimes what a venue asks for, but it means a
dead peer is only noticed when TCP notices. See the
crate::heartbeat module.
Sourcepub const fn reset_on_logon(self, reset: bool) -> Self
pub const fn reset_on_logon(self, reset: bool) -> Self
Sets whether the outbound Logon carries ResetSeqNumFlag (141) = Y.
Sourcepub const fn reset_on_logout(self, reset: bool) -> Self
pub const fn reset_on_logout(self, reset: bool) -> Self
Sets whether sequence numbers reset after a graceful Logout.
Sourcepub const fn reset_on_disconnect(self, reset: bool) -> Self
pub const fn reset_on_disconnect(self, reset: bool) -> Self
Sets whether sequence numbers reset when the session disconnects.
Sourcepub const fn max_message_size(self, size: usize) -> Self
pub const fn max_message_size(self, size: usize) -> Self
Sets the maximum accepted message size, in bytes.
Sourcepub const fn logon_timeout(self, timeout: Duration) -> Self
pub const fn logon_timeout(self, timeout: Duration) -> Self
Sets how long to wait for the Logon acknowledgement.
Non-zero, at most MAX_TIMEOUT.
Sourcepub const fn logout_timeout(self, timeout: Duration) -> Self
pub const fn logout_timeout(self, timeout: Duration) -> Self
Sets how long to wait for the Logout acknowledgement.
Non-zero, at most MAX_TIMEOUT.
Sourcepub const fn validate_checksum(self, validate: bool) -> Self
pub const fn validate_checksum(self, validate: bool) -> Self
Sets whether inbound CheckSum (10) is validated.
Sourcepub fn sender_sub_id(self, sub_id: impl Into<String>) -> Self
pub fn sender_sub_id(self, sub_id: impl Into<String>) -> Self
Sets the sender sub ID (tag 50).
1..=MAX_ID_LEN bytes of printable ASCII except =.
Sourcepub fn target_sub_id(self, sub_id: impl Into<String>) -> Self
pub fn target_sub_id(self, sub_id: impl Into<String>) -> Self
Sets the target sub ID (tag 57).
1..=MAX_ID_LEN bytes of printable ASCII except =.
Sourcepub fn sender_location_id(self, location_id: impl Into<String>) -> Self
pub fn sender_location_id(self, location_id: impl Into<String>) -> Self
Sets the sender location ID (tag 142).
1..=MAX_ID_LEN bytes of printable ASCII except =.
Sourcepub fn target_location_id(self, location_id: impl Into<String>) -> Self
pub fn target_location_id(self, location_id: impl Into<String>) -> Self
Sets the target location ID (tag 143).
1..=MAX_ID_LEN bytes of printable ASCII except =.
Sourcepub fn build(self) -> Result<SessionConfig, SessionConfigError>
pub fn build(self) -> Result<SessionConfig, SessionConfigError>
Builds the configuration, validating every knob.
§Errors
Returns SessionConfigError::MissingField if either CompID was never
set, and SessionConfigError::HeartbeatDisabledWithoutOptIn if
SessionConfigBuilder::heartbeat_interval was given
Duration::ZERO instead of calling
SessionConfigBuilder::disable_heartbeats. Everything else is the
first violation reported by SessionConfig::validate.
Trait Implementations§
Source§impl Clone for SessionConfigBuilder
impl Clone for SessionConfigBuilder
Source§fn clone(&self) -> SessionConfigBuilder
fn clone(&self) -> SessionConfigBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more