Skip to main content

Connection

Struct Connection 

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

Handle to a live FIX session.

Cloning is cheap; all clones refer to the same session. The session is closed when the transport drops, the counterparty logs out, a heartbeat timeout is detected, or Connection::logout completes.

§Dropping every handle logs out

The reactor stops when the last clone is dropped: it reads that as “nobody can drive this session any more” and performs a graceful Logout rather than leaving a task holding a socket forever. A consumer that wants the session to outlive its handle must keep one alive — typically by holding it until Connection::wait_closed returns.

Implementations§

Source§

impl Connection

Source

pub fn session_id(&self) -> &SessionId

Returns the session identifier.

Source

pub async fn send(&self, message: OutboundMessage) -> Result<(), EngineError>

Sends an application message on the session.

The engine stamps the standard header (including MsgSeqNum) and trailer; the message only needs body fields. It is checked here, before it is queued, so a message the session layer will not carry is refused to the caller rather than dropped later.

§Arguments
  • message - The application message to send
§Errors
§Accepted is not sent

Ok means the message was queued for the reactor, not that it reached the counterparty. A message queued while a Logout is already pending is dropped with a warning — the session is on its way out and a new application message would arrive after the Logout the counterparty has already seen. Use Connection::wait_closed to observe the end of the session and next_sender_seq to observe progress.

Source

pub async fn logout(&self) -> Result<(), EngineError>

Initiates a graceful logout.

A Logout message is sent to the counterparty; the session closes when the Logout acknowledgement arrives or the logout timeout elapses. Use Connection::wait_closed to observe completion.

§Errors

Returns EngineError::Closed if the session is already closed.

Source

pub async fn wait_closed(&self)

Waits until the session is closed.

Fires on transport drop, counterparty logout, heartbeat timeout, or completion of a locally initiated logout. Returns immediately if the session is already closed.

It fires after the inbound application messages already queued have been through from_app and on_logout has run, so a handler still in flight when the session ends delays this by however long it takes to finish, up to an internal drain bound.

Source

pub fn is_closed(&self) -> bool

Returns true if the session is closed.

Source

pub fn is_timed_out(&self) -> bool

Returns true if the session has detected a heartbeat timeout (a TestRequest went unanswered for a full heartbeat interval).

Source

pub fn next_sender_seq(&self) -> u64

Returns the next outgoing (sender) sequence number.

Source

pub fn next_target_seq(&self) -> u64

Returns the next expected incoming (target) sequence number.

Trait Implementations§

Source§

impl Clone for Connection

Source§

fn clone(&self) -> Connection

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Connection

Source§

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

Formats the value using the given formatter. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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