Skip to main content

SessionConfigBuilder

Struct SessionConfigBuilder 

Source
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

Source

pub fn new() -> Self

Creates a builder holding the defaults documented on SessionConfig::new.

Source

pub fn sender_comp_id(self, id: CompId) -> Self

Sets the sender CompID (tag 49). Required.

Source

pub fn target_comp_id(self, id: CompId) -> Self

Sets the target CompID (tag 56). Required.

Source

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 =.

Source

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.

Source

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.

Source

pub const fn reset_on_logon(self, reset: bool) -> Self

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

Source

pub const fn reset_on_logout(self, reset: bool) -> Self

Sets whether sequence numbers reset after a graceful Logout.

Source

pub const fn reset_on_disconnect(self, reset: bool) -> Self

Sets whether sequence numbers reset when the session disconnects.

Source

pub const fn max_message_size(self, size: usize) -> Self

Sets the maximum accepted message size, in bytes.

MIN_MESSAGE_SIZE_LIMIT..=MAX_MESSAGE_SIZE_LIMIT.

Source

pub const fn logon_timeout(self, timeout: Duration) -> Self

Sets how long to wait for the Logon acknowledgement.

Non-zero, at most MAX_TIMEOUT.

Source

pub const fn logout_timeout(self, timeout: Duration) -> Self

Sets how long to wait for the Logout acknowledgement.

Non-zero, at most MAX_TIMEOUT.

Source

pub const fn validate_checksum(self, validate: bool) -> Self

Sets whether inbound CheckSum (10) is validated.

Source

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 =.

Source

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 =.

Source

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 =.

Source

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 =.

Source

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

Source§

fn clone(&self) -> SessionConfigBuilder

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 SessionConfigBuilder

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for SessionConfigBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. 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, 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 = 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.