ironfix_session/lib.rs
1/******************************************************************************
2 Author: Joaquín Béjar García
3 Email: jb@taunais.com
4 Date: 27/1/26
5******************************************************************************/
6
7//! # IronFix Session
8//!
9//! FIX session layer protocol implementation for the IronFix engine.
10//!
11//! This crate is **pure protocol logic**: it performs no I/O, encodes no bytes
12//! and persists nothing. Its only IronFix dependency is `ironfix-core`.
13//!
14//! This crate provides:
15//! - **State machine**: a sealed typestate session FSM
16//! (`Disconnected` → `Connecting` → `LogonSent`/`LogonReceived` → `Active` →
17//! `Resending`/`LogoutPending`), so illegal transitions do not compile
18//! - **Sequence management**: [`SequenceManager`] with checked arithmetic —
19//! exhaustion is a typed error, never a silent wrap. Gap *detection*
20//! ([`SequenceResult::Gap`]) lives here; the recovery that follows
21//! (ResendRequest, SequenceReset, gap fill) is orchestrated by
22//! `ironfix-engine`, which owns the socket
23//! - **Heartbeat handling**: [`HeartbeatManager`], `Instant`-based timing for
24//! heartbeat and TestRequest deadlines and `HeartBtInt` negotiation
25//! - **Configuration**: [`SessionConfig`] and its validating
26//! [`config::SessionConfigBuilder`]
27//!
28//! Note that the `Resending` state is only the FSM marker for "a resend is in
29//! progress". The actual `ResendRequest` / `SequenceReset` / gap-fill message
30//! handling lives in `ironfix-engine`, because it requires the wire layer.
31
32pub mod config;
33pub mod heartbeat;
34pub mod sequence;
35pub mod state;
36
37pub use config::{SessionConfig, SessionConfigBuilder, SessionConfigError};
38pub use heartbeat::{
39 HeartbeatIntervalError, HeartbeatManager, MAX_HEARTBEAT_INTERVAL_SECS, TestRequestOutcome,
40 generate_test_req_id, negotiate_interval,
41};
42pub use sequence::{SequenceCounter, SequenceExhausted, SequenceManager, SequenceResult};
43pub use state::{
44 Active, Connecting, Disconnected, LogonReceived, LogonSent, LogoutPending, Resending, Session,
45 SessionState,
46};