Skip to content

Commit 1a7f8f6

Browse files
committed
Remove references to standard fix44 module
1 parent ae33e20 commit 1a7f8f6

5 files changed

Lines changed: 26 additions & 29 deletions

File tree

examples/custom-fields/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ license.workspace = true
77
publish = false
88

99
[dependencies]
10-
hotfix = { path = "../../crates/hotfix", features = ["fix44"] }
11-
hotfix-message = { path = "../../crates/hotfix-message", features = ["fix44"] }
10+
hotfix = { path = "../../crates/hotfix" }
11+
hotfix-message = { path = "../../crates/hotfix-message" }
1212

1313
anyhow.workspace = true
1414
async-trait.workspace = true
@@ -19,4 +19,4 @@ tracing-subscriber = { workspace = true, features = ["env-filter"] }
1919

2020
[build-dependencies]
2121
hotfix-codegen = { path = "../../crates/hotfix-codegen" }
22-
hotfix-dictionary = { path = "../../crates/hotfix-dictionary", features = ["fix44"] }
22+
hotfix-dictionary = { path = "../../crates/hotfix-dictionary" }

examples/custom-fields/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,21 @@ addition: a `<field number="6001" name="ClientStrategyId" type="INT"/>`
2424
in the `<fields>` block, plus an optional reference to it on
2525
`NewOrderSingle` and `ExecutionReport`.
2626

27-
## Mixing `hotfix::fix44` and `custom_fix`
27+
## Using the generated constants
2828

29-
The example uses stock field constants from `hotfix::fix44::*` (e.g.
30-
`fix44::CL_ORD_ID`) and the new constant from `custom_fix::CLIENT_STRATEGY_ID`.
31-
This is safe because the custom XML didn't change any FIX 4.4 tag — the
32-
`custom_fix` constants for stock tags are bit-for-bit identical to the ones
33-
in `hotfix::fix44`. If you'd prefer a single source of truth, switch your
34-
imports to `custom_fix::*` everywhere.
29+
All field constants and typed enums (`Side`, `OrdType`, `OrdStatus`, …) come
30+
from the `custom_fix` module — including the ones for standard FIX 4.4
31+
tags. This keeps the example aligned with a single source of truth: the
32+
custom XML drives both compile-time typing and runtime validation. The
33+
`hotfix::fix44` re-exports are deliberately not used here, so the
34+
`hotfix` dependency in `Cargo.toml` doesn't enable the `fix44` feature.
3535

3636
## Running the example
3737

38-
In one terminal, start the dummy executor:
38+
In one terminal, build and start the dummy executor via the existing compose file:
3939

4040
```shell
41-
cd dummy-executor && go run .
41+
docker compose -f example.compose.yml up --build dummy-executor
4242
```
4343

4444
In another, from the repo root, run the example:

examples/custom-fields/src/application.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ use std::sync::Arc;
33
use hotfix::Application;
44
use hotfix::Message;
55
use hotfix::application::{InboundDecision, OutboundDecision};
6-
use hotfix::fix44;
6+
use hotfix::message::Part;
77
use hotfix::session::Status;
8-
use hotfix_message::Part;
98
use tokio::sync::{Notify, mpsc};
109
use tracing::{info, warn};
1110

@@ -26,13 +25,13 @@ impl Application for TestApplication {
2625
}
2726

2827
async fn on_inbound_message(&self, msg: &Message) -> InboundDecision {
29-
let msg_type: Result<&str, _> = msg.header().get(hotfix_message::session_fields::MSG_TYPE);
28+
let msg_type: Result<&str, _> = msg.header().get(custom_fix::MSG_TYPE);
3029
if !matches!(msg_type, Ok("8")) {
3130
return InboundDecision::Accept;
3231
}
3332

34-
let cl_ord_id: Result<&str, _> = msg.get(fix44::CL_ORD_ID);
35-
let ord_status: Result<fix44::OrdStatus, _> = msg.get(fix44::ORD_STATUS);
33+
let cl_ord_id: Result<&str, _> = msg.get(custom_fix::CL_ORD_ID);
34+
let ord_status: Result<custom_fix::OrdStatus, _> = msg.get(custom_fix::ORD_STATUS);
3635
let client_strategy_id: Option<i32> = msg.get(custom_fix::CLIENT_STRATEGY_ID).ok();
3736

3837
match (cl_ord_id, ord_status) {

examples/custom-fields/src/main.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use anyhow::{Context, Result, anyhow};
99
use clap::Parser;
1010
use hotfix::config::Config;
1111
use hotfix::field_types::Timestamp;
12-
use hotfix::fix44;
1312
use hotfix::initiator::Initiator;
1413
use hotfix::store::in_memory::InMemoryMessageStore;
1514
use tokio::sync::{Notify, mpsc};
@@ -71,7 +70,7 @@ async fn main() -> Result<()> {
7170
let order = NewOrderSingle {
7271
cl_ord_id: CL_ORD_ID.to_string(),
7372
symbol: "EUR/USD".to_string(),
74-
side: fix44::Side::Buy,
73+
side: custom_fix::Side::Buy,
7574
order_qty: 100,
7675
transact_time: Timestamp::utc_now(),
7776
client_strategy_id: STRATEGY_ID,
@@ -128,7 +127,7 @@ async fn wait_for_fill(exec_rx: &mut mpsc::UnboundedReceiver<ExecReportSummary>)
128127
));
129128
}
130129

131-
if matches!(summary.ord_status, fix44::OrdStatus::Filled) {
130+
if matches!(summary.ord_status, custom_fix::OrdStatus::Filled) {
132131
info!("order filled, custom field round-tripped successfully");
133132
return Ok(());
134133
}

examples/custom-fields/src/messages.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use hotfix::Message as HotfixMessage;
22
use hotfix::field_types::Timestamp;
3-
use hotfix::fix44;
43
use hotfix::message::{OutboundMessage, Part};
54

65
use crate::custom_fix;
@@ -9,7 +8,7 @@ use crate::custom_fix;
98
pub struct NewOrderSingle {
109
pub cl_ord_id: String,
1110
pub symbol: String,
12-
pub side: fix44::Side,
11+
pub side: custom_fix::Side,
1312
pub order_qty: u32,
1413
pub transact_time: Timestamp,
1514
pub client_strategy_id: i32,
@@ -23,20 +22,20 @@ pub enum OutboundMsg {
2322
#[derive(Debug, Clone)]
2423
pub struct ExecReportSummary {
2524
pub cl_ord_id: String,
26-
pub ord_status: fix44::OrdStatus,
25+
pub ord_status: custom_fix::OrdStatus,
2726
pub client_strategy_id: Option<i32>,
2827
}
2928

3029
impl OutboundMessage for OutboundMsg {
3130
fn write(&self, msg: &mut HotfixMessage) {
3231
match self {
3332
OutboundMsg::NewOrderSingle(order) => {
34-
msg.set(fix44::CL_ORD_ID, order.cl_ord_id.as_str());
35-
msg.set(fix44::SYMBOL, order.symbol.as_str());
36-
msg.set(fix44::SIDE, order.side);
37-
msg.set(fix44::ORDER_QTY, order.order_qty);
38-
msg.set(fix44::TRANSACT_TIME, order.transact_time.clone());
39-
msg.set(fix44::ORD_TYPE, fix44::OrdType::Market);
33+
msg.set(custom_fix::CL_ORD_ID, order.cl_ord_id.as_str());
34+
msg.set(custom_fix::SYMBOL, order.symbol.as_str());
35+
msg.set(custom_fix::SIDE, order.side);
36+
msg.set(custom_fix::ORDER_QTY, order.order_qty);
37+
msg.set(custom_fix::TRANSACT_TIME, order.transact_time.clone());
38+
msg.set(custom_fix::ORD_TYPE, custom_fix::OrdType::Market);
4039
msg.set(custom_fix::CLIENT_STRATEGY_ID, order.client_strategy_id);
4140
}
4241
}

0 commit comments

Comments
 (0)