Skip to content

Commit b35988e

Browse files
committed
Reorganize common messages in Rust
1 parent 611ef72 commit b35988e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1708
-2606
lines changed

crates/common/src/messages/data/mod.rs

Lines changed: 38 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -21,88 +21,32 @@ use nautilus_model::{
2121
identifiers::{ClientId, Venue},
2222
};
2323

24-
pub mod request_bars;
25-
pub mod request_book_snapshot;
26-
pub mod request_data;
27-
pub mod request_instrument;
28-
pub mod request_instruments;
29-
pub mod request_quotes;
30-
pub mod request_trades;
31-
pub mod response_bars;
32-
pub mod response_book_snapshot;
33-
pub mod response_data;
34-
pub mod response_instrument;
35-
pub mod response_instruments;
36-
pub mod response_quotes;
37-
pub mod response_trades;
38-
pub mod subscribe_bars;
39-
pub mod subscribe_book_deltas;
40-
pub mod subscribe_book_depth10;
41-
pub mod subscribe_book_snapshots;
42-
pub mod subscribe_close;
43-
pub mod subscribe_data;
44-
pub mod subscribe_index_prices;
45-
pub mod subscribe_instrument;
46-
pub mod subscribe_instruments;
47-
pub mod subscribe_mark_prices;
48-
pub mod subscribe_quotes;
49-
pub mod subscribe_status;
50-
pub mod subscribe_trades;
51-
pub mod unsubscribe_bars;
52-
pub mod unsubscribe_book_deltas;
53-
pub mod unsubscribe_book_depth10;
54-
pub mod unsubscribe_book_snapshots;
55-
pub mod unsubscribe_close;
56-
pub mod unsubscribe_data;
57-
pub mod unsubscribe_index_prices;
58-
pub mod unsubscribe_instrument;
59-
pub mod unsubscribe_instruments;
60-
pub mod unsubscribe_mark_prices;
61-
pub mod unsubscribe_quotes;
62-
pub mod unsubscribe_status;
63-
pub mod unsubscribe_trades;
24+
pub mod request;
25+
pub mod response;
26+
pub mod subscribe;
27+
pub mod unsubscribe;
6428

6529
// Re-exports
66-
pub use request_bars::RequestBars;
67-
pub use request_book_snapshot::RequestBookSnapshot;
68-
pub use request_data::RequestCustomData;
69-
pub use request_instrument::RequestInstrument;
70-
pub use request_instruments::RequestInstruments;
71-
pub use request_quotes::RequestQuotes;
72-
pub use request_trades::RequestTrades;
73-
pub use response_bars::BarsResponse;
74-
pub use response_book_snapshot::BookResponse;
75-
pub use response_data::CustomDataResponse;
76-
pub use response_instrument::InstrumentResponse;
77-
pub use response_instruments::InstrumentsResponse;
78-
pub use response_quotes::QuotesResponse;
79-
pub use response_trades::TradesResponse;
80-
pub use subscribe_bars::SubscribeBars;
81-
pub use subscribe_book_deltas::SubscribeBookDeltas;
82-
pub use subscribe_book_depth10::SubscribeBookDepth10;
83-
pub use subscribe_book_snapshots::SubscribeBookSnapshots;
84-
pub use subscribe_close::SubscribeInstrumentClose;
85-
pub use subscribe_data::SubscribeCustomData;
86-
pub use subscribe_index_prices::SubscribeIndexPrices;
87-
pub use subscribe_instrument::SubscribeInstrument;
88-
pub use subscribe_instruments::SubscribeInstruments;
89-
pub use subscribe_mark_prices::SubscribeMarkPrices;
90-
pub use subscribe_quotes::SubscribeQuotes;
91-
pub use subscribe_status::SubscribeInstrumentStatus;
92-
pub use subscribe_trades::SubscribeTrades;
93-
pub use unsubscribe_bars::UnsubscribeBars;
94-
pub use unsubscribe_book_deltas::UnsubscribeBookDeltas;
95-
pub use unsubscribe_book_depth10::UnsubscribeBookDepth10;
96-
pub use unsubscribe_book_snapshots::UnsubscribeBookSnapshots;
97-
pub use unsubscribe_close::UnsubscribeInstrumentClose;
98-
pub use unsubscribe_data::UnsubscribeCustomData;
99-
pub use unsubscribe_index_prices::UnsubscribeIndexPrices;
100-
pub use unsubscribe_instrument::UnsubscribeInstrument;
101-
pub use unsubscribe_instruments::UnsubscribeInstruments;
102-
pub use unsubscribe_mark_prices::UnsubscribeMarkPrices;
103-
pub use unsubscribe_quotes::UnsubscribeQuotes;
104-
pub use unsubscribe_status::UnsubscribeInstrumentStatus;
105-
pub use unsubscribe_trades::UnsubscribeTrades;
30+
pub use request::{
31+
RequestBars, RequestBookSnapshot, RequestCustomData, RequestInstrument, RequestInstruments,
32+
RequestQuotes, RequestTrades,
33+
};
34+
pub use response::{
35+
BarsResponse, BookResponse, CustomDataResponse, InstrumentResponse, InstrumentsResponse,
36+
QuotesResponse, TradesResponse,
37+
};
38+
pub use subscribe::{
39+
SubscribeBars, SubscribeBookDeltas, SubscribeBookDepth10, SubscribeBookSnapshots,
40+
SubscribeCustomData, SubscribeIndexPrices, SubscribeInstrument, SubscribeInstrumentClose,
41+
SubscribeInstrumentStatus, SubscribeInstruments, SubscribeMarkPrices, SubscribeQuotes,
42+
SubscribeTrades,
43+
};
44+
pub use unsubscribe::{
45+
UnsubscribeBars, UnsubscribeBookDeltas, UnsubscribeBookDepth10, UnsubscribeBookSnapshots,
46+
UnsubscribeCustomData, UnsubscribeIndexPrices, UnsubscribeInstrument,
47+
UnsubscribeInstrumentClose, UnsubscribeInstrumentStatus, UnsubscribeInstruments,
48+
UnsubscribeMarkPrices, UnsubscribeQuotes, UnsubscribeTrades,
49+
};
10650

10751
#[derive(Clone, Debug, PartialEq)]
10852
pub enum DataCommand {
@@ -121,8 +65,8 @@ impl DataCommand {
12165
#[derive(Clone, Debug)]
12266
pub enum SubscribeCommand {
12367
Data(SubscribeCustomData),
124-
Instruments(SubscribeInstruments),
12568
Instrument(SubscribeInstrument),
69+
Instruments(SubscribeInstruments),
12670
BookDeltas(SubscribeBookDeltas),
12771
BookDepth10(SubscribeBookDepth10),
12872
BookSnapshots(SubscribeBookSnapshots),
@@ -150,8 +94,8 @@ impl SubscribeCommand {
15094
pub fn command_id(&self) -> UUID4 {
15195
match self {
15296
Self::Data(cmd) => cmd.command_id,
153-
Self::Instruments(cmd) => cmd.command_id,
15497
Self::Instrument(cmd) => cmd.command_id,
98+
Self::Instruments(cmd) => cmd.command_id,
15599
Self::BookDeltas(cmd) => cmd.command_id,
156100
Self::BookDepth10(cmd) => cmd.command_id,
157101
Self::BookSnapshots(cmd) => cmd.command_id,
@@ -168,8 +112,8 @@ impl SubscribeCommand {
168112
pub fn client_id(&self) -> Option<&ClientId> {
169113
match self {
170114
Self::Data(cmd) => cmd.client_id.as_ref(),
171-
Self::Instruments(cmd) => cmd.client_id.as_ref(),
172115
Self::Instrument(cmd) => cmd.client_id.as_ref(),
116+
Self::Instruments(cmd) => cmd.client_id.as_ref(),
173117
Self::BookDeltas(cmd) => cmd.client_id.as_ref(),
174118
Self::BookDepth10(cmd) => cmd.client_id.as_ref(),
175119
Self::BookSnapshots(cmd) => cmd.client_id.as_ref(),
@@ -186,8 +130,8 @@ impl SubscribeCommand {
186130
pub fn venue(&self) -> Option<&Venue> {
187131
match self {
188132
Self::Data(cmd) => cmd.venue.as_ref(),
189-
Self::Instruments(cmd) => Some(&cmd.venue),
190133
Self::Instrument(cmd) => cmd.venue.as_ref(),
134+
Self::Instruments(cmd) => Some(&cmd.venue),
191135
Self::BookDeltas(cmd) => cmd.venue.as_ref(),
192136
Self::BookDepth10(cmd) => cmd.venue.as_ref(),
193137
Self::BookSnapshots(cmd) => cmd.venue.as_ref(),
@@ -204,8 +148,8 @@ impl SubscribeCommand {
204148
pub fn ts_init(&self) -> UnixNanos {
205149
match self {
206150
Self::Data(cmd) => cmd.ts_init,
207-
Self::Instruments(cmd) => cmd.ts_init,
208151
Self::Instrument(cmd) => cmd.ts_init,
152+
Self::Instruments(cmd) => cmd.ts_init,
209153
Self::BookDeltas(cmd) => cmd.ts_init,
210154
Self::BookDepth10(cmd) => cmd.ts_init,
211155
Self::BookSnapshots(cmd) => cmd.ts_init,
@@ -223,8 +167,8 @@ impl SubscribeCommand {
223167
#[derive(Clone, Debug)]
224168
pub enum UnsubscribeCommand {
225169
Data(UnsubscribeCustomData),
226-
Instruments(UnsubscribeInstruments),
227170
Instrument(UnsubscribeInstrument),
171+
Instruments(UnsubscribeInstruments),
228172
BookDeltas(UnsubscribeBookDeltas),
229173
BookDepth10(UnsubscribeBookDepth10),
230174
BookSnapshots(UnsubscribeBookSnapshots),
@@ -252,8 +196,8 @@ impl UnsubscribeCommand {
252196
pub fn command_id(&self) -> UUID4 {
253197
match self {
254198
Self::Data(cmd) => cmd.command_id,
255-
Self::Instruments(cmd) => cmd.command_id,
256199
Self::Instrument(cmd) => cmd.command_id,
200+
Self::Instruments(cmd) => cmd.command_id,
257201
Self::BookDeltas(cmd) => cmd.command_id,
258202
Self::BookDepth10(cmd) => cmd.command_id,
259203
Self::BookSnapshots(cmd) => cmd.command_id,
@@ -270,8 +214,8 @@ impl UnsubscribeCommand {
270214
pub fn client_id(&self) -> Option<&ClientId> {
271215
match self {
272216
Self::Data(cmd) => cmd.client_id.as_ref(),
273-
Self::Instruments(cmd) => cmd.client_id.as_ref(),
274217
Self::Instrument(cmd) => cmd.client_id.as_ref(),
218+
Self::Instruments(cmd) => cmd.client_id.as_ref(),
275219
Self::BookDeltas(cmd) => cmd.client_id.as_ref(),
276220
Self::BookDepth10(cmd) => cmd.client_id.as_ref(),
277221
Self::BookSnapshots(cmd) => cmd.client_id.as_ref(),
@@ -288,8 +232,8 @@ impl UnsubscribeCommand {
288232
pub fn venue(&self) -> Option<&Venue> {
289233
match self {
290234
Self::Data(cmd) => cmd.venue.as_ref(),
291-
Self::Instruments(cmd) => Some(&cmd.venue),
292235
Self::Instrument(cmd) => cmd.venue.as_ref(),
236+
Self::Instruments(cmd) => Some(&cmd.venue),
293237
Self::BookDeltas(cmd) => cmd.venue.as_ref(),
294238
Self::BookDepth10(cmd) => cmd.venue.as_ref(),
295239
Self::BookSnapshots(cmd) => cmd.venue.as_ref(),
@@ -306,8 +250,8 @@ impl UnsubscribeCommand {
306250
pub fn ts_init(&self) -> UnixNanos {
307251
match self {
308252
Self::Data(cmd) => cmd.ts_init,
309-
Self::Instruments(cmd) => cmd.ts_init,
310253
Self::Instrument(cmd) => cmd.ts_init,
254+
Self::Instruments(cmd) => cmd.ts_init,
311255
Self::BookDeltas(cmd) => cmd.ts_init,
312256
Self::BookDepth10(cmd) => cmd.ts_init,
313257
Self::BookSnapshots(cmd) => cmd.ts_init,
@@ -355,8 +299,8 @@ impl RequestCommand {
355299
pub fn request_id(&self) -> &UUID4 {
356300
match self {
357301
Self::Data(cmd) => &cmd.request_id,
358-
Self::Instruments(cmd) => &cmd.request_id,
359302
Self::Instrument(cmd) => &cmd.request_id,
303+
Self::Instruments(cmd) => &cmd.request_id,
360304
Self::BookSnapshot(cmd) => &cmd.request_id,
361305
Self::Quotes(cmd) => &cmd.request_id,
362306
Self::Trades(cmd) => &cmd.request_id,
@@ -367,8 +311,8 @@ impl RequestCommand {
367311
pub fn client_id(&self) -> Option<&ClientId> {
368312
match self {
369313
Self::Data(cmd) => Some(&cmd.client_id),
370-
Self::Instruments(cmd) => cmd.client_id.as_ref(),
371314
Self::Instrument(cmd) => cmd.client_id.as_ref(),
315+
Self::Instruments(cmd) => cmd.client_id.as_ref(),
372316
Self::BookSnapshot(cmd) => cmd.client_id.as_ref(),
373317
Self::Quotes(cmd) => cmd.client_id.as_ref(),
374318
Self::Trades(cmd) => cmd.client_id.as_ref(),
@@ -379,8 +323,8 @@ impl RequestCommand {
379323
pub fn venue(&self) -> Option<&Venue> {
380324
match self {
381325
Self::Data(_) => None,
382-
Self::Instruments(cmd) => cmd.venue.as_ref(),
383326
Self::Instrument(cmd) => Some(&cmd.instrument_id.venue),
327+
Self::Instruments(cmd) => cmd.venue.as_ref(),
384328
Self::BookSnapshot(cmd) => Some(&cmd.instrument_id.venue),
385329
Self::Quotes(cmd) => Some(&cmd.instrument_id.venue),
386330
Self::Trades(cmd) => Some(&cmd.instrument_id.venue),
@@ -395,8 +339,8 @@ impl RequestCommand {
395339
pub fn ts_init(&self) -> UnixNanos {
396340
match self {
397341
Self::Data(cmd) => cmd.ts_init,
398-
Self::Instruments(cmd) => cmd.ts_init,
399342
Self::Instrument(cmd) => cmd.ts_init,
343+
Self::Instruments(cmd) => cmd.ts_init,
400344
Self::BookSnapshot(cmd) => cmd.ts_init,
401345
Self::Quotes(cmd) => cmd.ts_init,
402346
Self::Trades(cmd) => cmd.ts_init,

0 commit comments

Comments
 (0)