nautilus_model/identifiers/
mod.rs

1// -------------------------------------------------------------------------------------------------
2//  Copyright (C) 2015-2025 Nautech Systems Pty Ltd. All rights reserved.
3//  https://nautechsystems.io
4//
5//  Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6//  You may not use this file except in compliance with the License.
7//  You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8//
9//  Unless required by applicable law or agreed to in writing, software
10//  distributed under the License is distributed on an "AS IS" BASIS,
11//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//  See the License for the specific language governing permissions and
13//  limitations under the License.
14// -------------------------------------------------------------------------------------------------
15
16//! Identifiers for the trading domain model.
17
18use serde::{Deserialize, Deserializer, Serialize, Serializer};
19
20#[macro_use]
21mod macros;
22
23pub mod account_id;
24pub mod client_id;
25pub mod client_order_id;
26pub mod component_id;
27pub mod default;
28pub mod exec_algorithm_id;
29pub mod instrument_id;
30pub mod order_list_id;
31pub mod position_id;
32pub mod strategy_id;
33pub mod symbol;
34pub mod trade_id;
35pub mod trader_id;
36pub mod venue;
37pub mod venue_order_id;
38
39#[cfg(feature = "stubs")]
40pub mod stubs;
41
42// Re-exports
43pub use crate::identifiers::{
44    account_id::AccountId, client_id::ClientId, client_order_id::ClientOrderId,
45    component_id::ComponentId, exec_algorithm_id::ExecAlgorithmId, instrument_id::InstrumentId,
46    order_list_id::OrderListId, position_id::PositionId, strategy_id::StrategyId, symbol::Symbol,
47    trade_id::TradeId, trader_id::TraderId, venue::Venue, venue_order_id::VenueOrderId,
48};
49
50impl_from_str_for_identifier!(account_id::AccountId);
51impl_from_str_for_identifier!(client_id::ClientId);
52impl_from_str_for_identifier!(client_order_id::ClientOrderId);
53impl_from_str_for_identifier!(component_id::ComponentId);
54impl_from_str_for_identifier!(exec_algorithm_id::ExecAlgorithmId);
55impl_from_str_for_identifier!(order_list_id::OrderListId);
56impl_from_str_for_identifier!(position_id::PositionId);
57impl_from_str_for_identifier!(strategy_id::StrategyId);
58impl_from_str_for_identifier!(symbol::Symbol);
59impl_from_str_for_identifier!(trade_id::TradeId);
60impl_from_str_for_identifier!(trader_id::TraderId);
61impl_from_str_for_identifier!(venue::Venue);
62impl_from_str_for_identifier!(venue_order_id::VenueOrderId);
63
64impl_serialization_for_identifier!(account_id::AccountId);
65impl_serialization_for_identifier!(client_id::ClientId);
66impl_serialization_for_identifier!(client_order_id::ClientOrderId);
67impl_serialization_for_identifier!(component_id::ComponentId);
68impl_serialization_for_identifier!(exec_algorithm_id::ExecAlgorithmId);
69impl_serialization_for_identifier!(order_list_id::OrderListId);
70impl_serialization_for_identifier!(position_id::PositionId);
71impl_serialization_for_identifier!(strategy_id::StrategyId);
72impl_serialization_for_identifier!(symbol::Symbol);
73impl_serialization_for_identifier!(trader_id::TraderId);
74impl_serialization_for_identifier!(venue::Venue);
75impl_serialization_for_identifier!(venue_order_id::VenueOrderId);
76
77impl_as_ref_for_identifier!(account_id::AccountId);
78impl_as_ref_for_identifier!(client_id::ClientId);
79impl_as_ref_for_identifier!(client_order_id::ClientOrderId);
80impl_as_ref_for_identifier!(component_id::ComponentId);
81impl_as_ref_for_identifier!(exec_algorithm_id::ExecAlgorithmId);
82impl_as_ref_for_identifier!(order_list_id::OrderListId);
83impl_as_ref_for_identifier!(position_id::PositionId);
84impl_as_ref_for_identifier!(strategy_id::StrategyId);
85impl_as_ref_for_identifier!(symbol::Symbol);
86impl_as_ref_for_identifier!(trader_id::TraderId);
87impl_as_ref_for_identifier!(venue::Venue);
88impl_as_ref_for_identifier!(venue_order_id::VenueOrderId);
89
90#[no_mangle]
91pub extern "C" fn interned_string_stats() {
92    dbg!(ustr::total_allocated());
93    dbg!(ustr::total_capacity());
94
95    ustr::string_cache_iter().for_each(|s| println!("{s}"));
96}