Skip to main content

Module session

Module session 

Source
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 handshakebuild_logon emits a Logon with HeartBtInt(108) and an optional ResetSeqNumFlag(141); an inbound Logon transitions the session to SessionState::Active.
  • Heartbeats / test requestsheartbeat emits a Heartbeat on the configured interval; an inbound TestRequest(1) is answered with a Heartbeat echoing TestReqID(112).
  • Sequence management — every outbound message is stamped with the next MsgSeqNum from the FixSeqStore; every accepted inbound message advances the expected-inbound counter.
  • Gap detection + resend — an inbound message whose MsgSeqNum is higher than expected triggers a ResendRequest(2) for the gap range.
  • Resend / gap-fill — an inbound ResendRequest(2) is answered with a SequenceReset(4) carrying GapFillFlag(123)=Y (administrative messages are never resent; the gap is filled instead).
  • SequenceReset — an inbound SequenceReset advances the expected inbound counter to NewSeqNo(36).
  • Orderly logoutbuild_logout emits a Logout; an inbound Logout is answered (if we did not initiate) and the session returns to SessionState::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 with PossDupFlag(43)=Y. The hook for that is FixSession::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.
FixSessionConfig
Static configuration for a session.
InboundOutcome
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.
SessionState
Lifecycle state of the session FSM.