FixApplication

Trait FixApplication 

pub trait FixApplication: Send + 'static {
    // Provided methods
    fn process(&mut self, _msg: &FixMessage, _session: &Session) -> bool { ... }
    fn on_logon(
        &mut self,
        event: &mut LogonEvent<'_>,
        _session_id: &SessionIdWrapper,
    ) { ... }
    fn on_logout(
        &mut self,
        _event: &mut LogoutEvent<'_>,
        _session_id: &SessionIdWrapper,
    ) { ... }
    fn on_session_level_reject(
        &mut self,
        _event: &SessionLevelRejectEvent<'_>,
        _session_id: &SessionIdWrapper,
    ) { ... }
    fn on_msg_reject(
        &mut self,
        _event: &MsgRejectEvent<'_>,
        _session_id: &SessionIdWrapper,
    ) { ... }
    fn on_new_state(
        &mut self,
        _event: &NewStateEvent<'_>,
        _session_id: &SessionIdWrapper,
    ) { ... }
    fn on_resend(
        &mut self,
        _msg: &FixMessage,
        _session_id: &SessionIdWrapper,
    ) -> bool { ... }
}
Expand description

Trait for handling FIX session events

Implement this trait to define custom behavior for your FIX application. All methods have default implementations, so override only what you need.

§Thread Safety

Callbacks may be called from different threads. The Send + 'static bounds ensure the implementation can be safely sent between threads.

§Lifetimes

Event objects (LogonEvent, LogoutEvent, etc.) are only valid within the callback scope. Do not store references to them.

Provided Methods§

fn process(&mut self, _msg: &FixMessage, _session: &Session) -> bool

Process incoming business message

Called when a business-level FIX message is received (not session-level). This is the main callback for handling application messages.

§Arguments
  • msg - The incoming FIX message (borrowed, valid during callback)
  • session - The session that received the message
§Returns
  • true - Message was processed successfully
  • false - Message could not be processed (will be retried later)
§Performance

This method is latency-sensitive. Minimize allocations and I/O here. The message is borrowed (zero-copy) from C++.

§Default

Returns true (accepts all messages without processing)

fn on_logon( &mut self, event: &mut LogonEvent<'_>, _session_id: &SessionIdWrapper, )

Handle logon event

Called when a Logon message is received from the counterparty. Use this to accept/reject connections and customize the logon response.

§Arguments
  • event - Mutable logon event (set logon_action to control response)
  • session_id - The session identifier
§Default

Accepts the logon with confirmation (AcceptWithConfirmLogon)

fn on_logout( &mut self, _event: &mut LogoutEvent<'_>, _session_id: &SessionIdWrapper, )

Handle logout event

Called when the session is closed (either by logout message or disconnect). Use this to decide whether to reconnect.

§Arguments
  • event - Mutable logout event (set reconnect_flag if needed)
  • session_id - The session identifier
§Warning

Do not set reconnect_flag = true during application shutdown, as it will cause an infinite reconnection loop.

§Default

Does nothing (no automatic reconnection)

fn on_session_level_reject( &mut self, _event: &SessionLevelRejectEvent<'_>, _session_id: &SessionIdWrapper, )

Handle session-level reject

Called when a SessionReject (MsgType=3) message is received.

§Arguments
  • event - The reject event containing the reject message
  • session_id - The session identifier
§Default

Does nothing

fn on_msg_reject( &mut self, _event: &MsgRejectEvent<'_>, _session_id: &SessionIdWrapper, )

Handle message reject

Called when a message has been rejected.

§Arguments
  • event - The reject event containing the rejected message
  • session_id - The session identifier
§Default

Does nothing

fn on_new_state( &mut self, _event: &NewStateEvent<'_>, _session_id: &SessionIdWrapper, )

Handle session state change

Called when the session transitions between states (e.g., Initial → Established).

§Arguments
  • event - The state change event with old and new states
  • session_id - The session identifier
§Default

Does nothing

fn on_resend( &mut self, _msg: &FixMessage, _session_id: &SessionIdWrapper, ) -> bool

Handle resend decision

Called when an outgoing message is about to be resent due to a ResendRequest. Return true to resend the message, false to send a SequenceReset-GapFill instead.

§Arguments
  • msg - The message that would be resent
  • session_id - The session identifier
§Returns
  • true - Resend the message
  • false - Send SequenceReset-GapFill instead
§Default

Returns true (always resend)

Implementors§