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
impl SequenceManager
Sourcepub fn with_initial(sender_seq: u64, target_seq: u64) -> Self
pub fn with_initial(sender_seq: u64, target_seq: u64) -> Self
Creates a new sequence manager with specified starting values.
§Arguments
sender_seq- Initial sender sequence numbertarget_seq- Initial target sequence number
Sourcepub fn next_sender_seq(&self) -> SeqNum
pub fn next_sender_seq(&self) -> SeqNum
Returns the next sender sequence number without incrementing.
Sourcepub fn next_target_seq(&self) -> SeqNum
pub fn next_target_seq(&self) -> SeqNum
Returns the next target sequence number without incrementing.
Sourcepub fn allocate_sender_seq(&self) -> SeqNum
pub fn allocate_sender_seq(&self) -> SeqNum
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.
Sourcepub fn try_allocate_sender_seq(&self) -> Result<SeqNum, SequenceExhausted>
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.
Sourcepub fn increment_target_seq(&self)
pub fn increment_target_seq(&self)
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.
Sourcepub fn try_increment_target_seq(&self) -> Result<SeqNum, SequenceExhausted>
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.