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
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 successfullyfalse- 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,
)
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 (setlogon_actionto 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,
)
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 (setreconnect_flagif 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,
)
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_msg_reject( &mut self, _event: &MsgRejectEvent<'_>, _session_id: &SessionIdWrapper, )
fn on_new_state(
&mut self,
_event: &NewStateEvent<'_>,
_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
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 resentsession_id- The session identifier
§Returns
true- Resend the messagefalse- Send SequenceReset-GapFill instead
§Default
Returns true (always resend)