Skip to main content

SequenceManager

Struct SequenceManager 

Source
pub struct SequenceManager { /* private fields */ }
Expand description

Manages sequence numbers for a FIX session.

Uses atomic operations for thread-safe access without locks.

Implementations§

Source§

impl SequenceManager

Source

pub fn new() -> Self

Creates a new sequence manager with sequence numbers starting at 1.

Source

pub const fn with_initial( sender_seq: NonZeroU64, target_seq: NonZeroU64, ) -> Self

Creates a new sequence manager seeded with the given starting values.

Both counters are NonZeroU64: FIX numbers messages from 1, and a MsgSeqNum (34) of 0 is rejected by every conforming counterparty. Taking NonZeroU64 makes a zero seed unrepresentable at the type level, so a 34=0 can never be seeded onto the wire — the invalid state is refused at the call site rather than caught at runtime.

§Arguments
  • sender_seq - Next outgoing sequence number, >= 1
  • target_seq - Next expected incoming sequence number, >= 1
Source

pub fn next_sender_seq(&self) -> SeqNum

Returns the next sender sequence number without incrementing.

Source

pub fn next_target_seq(&self) -> SeqNum

Returns the next target sequence number without incrementing.

Source

pub fn allocate_sender_seq(&self) -> SeqNum

👎Deprecated since 0.4.0:

wraps silently on overflow, which corrupts a live session; use try_allocate_sender_seq. Removed in the next breaking release.

Allocates and returns the next sender sequence number.

This atomically increments the sequence number and returns the value before the increment.

Note: wraps silently on u64 overflow. Prefer try_allocate_sender_seq for venue-grade sessions where exhaustion must be an explicit error.

Source

pub fn try_allocate_sender_seq(&self) -> Result<SeqNum, SequenceExhausted>

Allocates and returns the next sender sequence number, failing instead of wrapping when the counter is exhausted.

On success this atomically increments the counter and returns the value before the increment. On exhaustion the counter is left untouched; the session must perform a sequence reset (see SequenceExhausted) before more numbers can be allocated.

§Errors

Returns SequenceExhausted if the counter has reached u64::MAX.

Source

pub fn increment_target_seq(&self)

👎Deprecated since 0.4.0:

wraps silently on overflow, which corrupts a live session; use try_increment_target_seq. Removed in the next breaking release.

Increments the target sequence number.

Call this after successfully processing an incoming message.

Note: wraps silently on u64 overflow. Prefer try_increment_target_seq for venue-grade sessions where exhaustion must be an explicit error.

Source

pub fn try_increment_target_seq(&self) -> Result<SeqNum, SequenceExhausted>

Increments the target sequence number, failing instead of wrapping when the counter is exhausted.

On success returns the new next expected target sequence number. On exhaustion the counter is left untouched; the session must perform a sequence reset (see SequenceExhausted) before more messages can be accepted.

§Errors

Returns SequenceExhausted if the counter has reached u64::MAX.

Source

pub fn set_sender_seq(&self, seq: u64)

Sets the next sender sequence number.

§Arguments
Source

pub fn set_target_seq(&self, seq: u64)

Sets the next target sequence number.

§Arguments
Source

pub fn reset(&self)

Resets both sequence numbers to 1.

Source

pub fn validate_incoming(&self, received: u64) -> SequenceResult

Validates an incoming MsgSeqNum (34) against the next expected target sequence number.

This only classifies; it moves no counter. Acting on the answer — a ResendRequest for a gap, a PossDupFlag check for a duplicate — is the engine’s job.

§Arguments
  • received - The received sequence number
§Returns

Trait Implementations§

Source§

impl Debug for SequenceManager

Source§

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

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

impl Default for SequenceManager

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