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 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 number
  • target_seq - Initial target sequence number
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

Allocates and returns the next sender sequence number.

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

Source

pub fn increment_target_seq(&self)

Increments the target sequence number.

Call this after successfully processing an incoming message.

Source

pub fn set_sender_seq(&self, seq: u64)

Sets the next sender sequence number.

§Arguments
  • seq - The new sequence number
Source

pub fn set_target_seq(&self, seq: u64)

Sets the next target sequence number.

§Arguments
  • seq - The new sequence number
Source

pub fn reset(&self)

Resets both sequence numbers to 1.

Source

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

Validates an incoming sequence number.

§Arguments
  • received - The received sequence number
§Returns
  • Ok(()) if the sequence number matches expected
  • Err(SequenceResult::TooLow) if it’s a possible duplicate
  • Err(SequenceResult::Gap) if there’s a gap

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.