Skip to main content

Acceptor

Struct Acceptor 

Source
pub struct Acceptor<A: Application = NoOpApplication> { /* private fields */ }
Expand description

Server-side FIX engine.

Owns the session configuration and the Application callbacks. Each accepted connection (Acceptor::accept / Acceptor::serve) establishes one live session and returns a Connection handle for it. Cloning the application is cheap, so an Acceptor is typically wrapped in an Arc and shared across the tasks serving each connection.

The configuration is stated from the acceptor’s point of view: its sender_comp_id is the acceptor’s own CompID and its target_comp_id is the initiator it expects — the reverse of what the peer stamps on the wire, which is exactly what the inbound-identity check validates against.

Implementations§

Source§

impl<A: Application + 'static> Acceptor<A>

Source

pub fn new(config: SessionConfig, application: Arc<A>) -> Self

Creates a new acceptor.

§Arguments
  • config - The session configuration (sender = this acceptor’s CompID, target = the initiator it expects)
  • application - The application callback handler
Source

pub fn with_initial_sequences(self, sender_seq: u64, target_seq: u64) -> Self

Seeds each accepted session with initial sequence numbers, for continuity with a previous session. Ignored when the inbound Logon carries ResetSeqNumFlag (141) = Y, which resets both counters to 1.

§Arguments
  • sender_seq - Next outgoing sequence number
  • target_seq - Next expected incoming sequence number
Source

pub fn with_outbound_capacity(self, capacity: usize) -> Self

Sets the capacity of each session’s outbound message queue (default 1024).

Source

pub fn config(&self) -> &SessionConfig

Returns the session configuration.

Source

pub fn session_id(&self) -> &SessionId

Returns the session identifier.

Source

pub async fn accept( &self, listener: &TcpListener, ) -> Result<Connection, EngineError>

Accepts the next inbound connection on listener and establishes a session on it.

This is a thin convenience over Acceptor::serve: it awaits one TCP connection and hands the stream to the handshake. For concurrent handshakes, run the accept loop yourself and spawn a serve per connection (see the module example).

§Arguments
§Errors

Returns EngineError::Io if the TCP accept fails, or any error Acceptor::serve can produce.

Source

pub async fn serve(&self, stream: TcpStream) -> Result<Connection, EngineError>

Establishes a session on an already-accepted TcpStream, completing the acceptor-side Logon handshake and spawning the session reactor.

On success the session is Active: on_logon has fired and the returned Connection can send application messages. The reactor owns the socket and handles heartbeats, TestRequests, sequence validation, and admin replies until the session closes.

§Arguments
  • stream - An accepted TCP connection from the counterparty
§Errors

Returns an EngineError if framing or the Logon handshake fails. That includes EngineError::LogonTimeout when no Logon arrives within SessionConfig::logon_timeout, EngineError::UnexpectedMessage when the first frame is not a Logon, EngineError::IdentityMismatch when the Logon’s CompIDs do not match the configured counterparty, and EngineError::SequenceExhausted when a sequence counter has reached u64::MAX. EngineError::LogonRejected covers the acceptor-side refusals: the from_admin authentication hook, a BeginString (8) that does not match this session’s version, an unsupported EncryptMethod (98), a HeartBtInt (108) that is missing, non-numeric, or out of range, and a second concurrent Logon for a session already established. A BeginString this engine cannot frame at all is refused up front with EngineError::UnsupportedVersion.

Trait Implementations§

Source§

impl<A: Debug + Application> Debug for Acceptor<A>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<A> Freeze for Acceptor<A>
where Arc<A>: Freeze,

§

impl<A> RefUnwindSafe for Acceptor<A>
where Arc<A>: RefUnwindSafe,

§

impl<A> Send for Acceptor<A>
where Arc<A>: Send,

§

impl<A> Sync for Acceptor<A>
where Arc<A>: Sync,

§

impl<A> Unpin for Acceptor<A>
where Arc<A>: Unpin,

§

impl<A> UnsafeUnpin for Acceptor<A>
where Arc<A>: UnsafeUnpin,

§

impl<A> UnwindSafe for Acceptor<A>
where Arc<A>: UnwindSafe,

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more