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// -------------------------------------------------------------------------------------------------
1516//! Identifiers for the trading domain model.
1718use serde::{Deserialize, Deserializer, Serialize, Serializer};
1920#[macro_use]
21mod macros;
2223pub mod account_id;
24pub mod actor_id;
25pub mod client_id;
26pub mod client_order_id;
27pub mod component_id;
28pub mod default;
29pub mod exec_algorithm_id;
30pub mod instrument_id;
31pub mod order_list_id;
32pub mod position_id;
33pub mod strategy_id;
34pub mod symbol;
35pub mod trade_id;
36pub mod trader_id;
37pub mod venue;
38pub mod venue_order_id;
3940#[cfg(feature = "stubs")]
41pub mod stubs;
4243// Re-exports
44pub use crate::identifiers::{
45 account_id::AccountId, actor_id::ActorId, client_id::ClientId, client_order_id::ClientOrderId,
46 component_id::ComponentId, exec_algorithm_id::ExecAlgorithmId, instrument_id::InstrumentId,
47 order_list_id::OrderListId, position_id::PositionId, strategy_id::StrategyId, symbol::Symbol,
48 trade_id::TradeId, trader_id::TraderId, venue::Venue, venue_order_id::VenueOrderId,
49};
5051impl_from_str_for_identifier!(account_id::AccountId);
52impl_from_str_for_identifier!(actor_id::ActorId);
53impl_from_str_for_identifier!(client_id::ClientId);
54impl_from_str_for_identifier!(client_order_id::ClientOrderId);
55impl_from_str_for_identifier!(component_id::ComponentId);
56impl_from_str_for_identifier!(exec_algorithm_id::ExecAlgorithmId);
57impl_from_str_for_identifier!(order_list_id::OrderListId);
58impl_from_str_for_identifier!(position_id::PositionId);
59impl_from_str_for_identifier!(strategy_id::StrategyId);
60impl_from_str_for_identifier!(symbol::Symbol);
61impl_from_str_for_identifier!(trade_id::TradeId);
62impl_from_str_for_identifier!(trader_id::TraderId);
63impl_from_str_for_identifier!(venue::Venue);
64impl_from_str_for_identifier!(venue_order_id::VenueOrderId);
6566impl_serialization_for_identifier!(account_id::AccountId);
67impl_serialization_for_identifier!(actor_id::ActorId);
68impl_serialization_for_identifier!(client_id::ClientId);
69impl_serialization_for_identifier!(client_order_id::ClientOrderId);
70impl_serialization_for_identifier!(component_id::ComponentId);
71impl_serialization_for_identifier!(exec_algorithm_id::ExecAlgorithmId);
72impl_serialization_for_identifier!(order_list_id::OrderListId);
73impl_serialization_for_identifier!(position_id::PositionId);
74impl_serialization_for_identifier!(strategy_id::StrategyId);
75impl_serialization_for_identifier!(symbol::Symbol);
76impl_serialization_for_identifier!(trader_id::TraderId);
77impl_serialization_for_identifier!(venue::Venue);
78impl_serialization_for_identifier!(venue_order_id::VenueOrderId);
7980impl_as_ref_for_identifier!(account_id::AccountId);
81impl_as_ref_for_identifier!(actor_id::ActorId);
82impl_as_ref_for_identifier!(client_id::ClientId);
83impl_as_ref_for_identifier!(client_order_id::ClientOrderId);
84impl_as_ref_for_identifier!(component_id::ComponentId);
85impl_as_ref_for_identifier!(exec_algorithm_id::ExecAlgorithmId);
86impl_as_ref_for_identifier!(order_list_id::OrderListId);
87impl_as_ref_for_identifier!(position_id::PositionId);
88impl_as_ref_for_identifier!(strategy_id::StrategyId);
89impl_as_ref_for_identifier!(symbol::Symbol);
90impl_as_ref_for_identifier!(trader_id::TraderId);
91impl_as_ref_for_identifier!(venue::Venue);
92impl_as_ref_for_identifier!(venue_order_id::VenueOrderId);
9394#[unsafe(no_mangle)]
95pub extern "C" fn interned_string_stats() {
96dbg!(ustr::total_allocated());
97dbg!(ustr::total_capacity());
9899 ustr::string_cache_iter().for_each(|s| println!("{s}"));
100}