Expand description
FIX session-state machine.
FixSession is a self-contained, runtime-agnostic driver for the FIX
session layer. It is deliberately not an atomr Actor: the FSM is a
plain async struct whose transitions are exercised by feeding it inbound
FixMessages and observing the outbound messages it produces. This makes
the protocol logic unit-testable without a socket. A thin run
helper wires the same FSM onto an atomr-streams TCP connection +
SOH framing for real deployments.
§What the FSM covers
- Logon handshake —
build_logonemits a Logon withHeartBtInt(108)and an optionalResetSeqNumFlag(141); an inbound Logon transitions the session toSessionState::Active. - Heartbeats / test requests —
heartbeatemits a Heartbeat on the configured interval; an inboundTestRequest(1)is answered with a Heartbeat echoingTestReqID(112). - Sequence management — every outbound message is stamped with the next
MsgSeqNumfrom theFixSeqStore; every accepted inbound message advances the expected-inbound counter. - Gap detection + resend — an inbound message whose
MsgSeqNumis higher than expected triggers aResendRequest(2)for the gap range. - Resend / gap-fill — an inbound
ResendRequest(2)is answered with aSequenceReset(4)carryingGapFillFlag(123)=Y(administrative messages are never resent; the gap is filled instead). - SequenceReset — an inbound
SequenceResetadvances the expected inbound counter toNewSeqNo(36). - Orderly logout —
build_logoutemits a Logout; an inbound Logout is answered (if we did not initiate) and the session returns toSessionState::Disconnected.
§Template-level simplifications
This is a real FSM, not a toy, but a few production behaviours are left as documented extension points rather than implemented:
- Resend of application messages replays via
SequenceReset-GapFill only; a real engine would keep a per-session outbound message log and resend the original application messages withPossDupFlag(43)=Y. The hook for that isFixSession::set_outbound_log-style storage, intentionally omitted to keep the store contract narrow. PossResend(97)/OrigSendingTime(122)handling on inbound duplicates, message-level validation (required-field / value checks beyond the header), and logon authentication are out of scope.
Structs§
- FixSession
- The driver. Holds the FSM state, config, and the sequence store.
- FixSession
Config - Static configuration for a session.
- Inbound
Outcome - The result of
FixSession::handle_inbound.
Enums§
- FixVersion
- FIX protocol version, selected at runtime (not via cargo features) so the default build exercises every begin-string branch.
- Session
State - Lifecycle state of the session FSM.