1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use crate::message::OutboundMessage;
use crate::session::Status;
use hotfix_message::message::Message;
#[async_trait::async_trait]
/// The application users of HotFIX can implement to hook into the engine.
pub trait Application: Send + Sync + 'static {
type Outbound: OutboundMessage;
/// Called when a message is sent to the engine to be sent to the counterparty.
///
/// This is invoked before the raw message is persisted in the message store.
async fn on_outbound_message(&self, msg: &Self::Outbound) -> OutboundDecision;
/// Called when a message is received from the counterparty.
///
/// This is invoked after the message is verified by the session layer.
async fn on_inbound_message(&self, msg: &Message) -> InboundDecision;
/// Called when the session is logged out.
async fn on_logout(&mut self, reason: &str);
/// Called when the session is logged on.
async fn on_logon(&mut self);
/// Called when the session state changes.
///
/// This is invoked after every state transition, providing the previous
/// and new status. The default implementation does nothing.
async fn on_state_change(&self, from: &Status, to: &Status);
}
/// Standard FIX Business Reject Reason values (tag 380).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u32)]
pub enum BusinessRejectReason {
Other = 0,
UnknownId = 1,
UnknownSecurity = 2,
UnsupportedMessageType = 3,
ApplicationNotAvailable = 4,
ConditionallyRequiredFieldMissing = 5,
NotAuthorized = 6,
DeliverToFirmNotAvailable = 7,
}
pub enum InboundDecision {
Accept,
Reject {
reason: BusinessRejectReason,
text: Option<String>,
},
TerminateSession,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum OutboundDecision {
Send,
Drop,
TerminateSession,
}