nautilus_model/
venues.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//! Common `Venue` constants.
17
18use std::{
19    collections::HashMap,
20    sync::{Mutex, OnceLock},
21};
22
23use once_cell::sync::Lazy;
24
25use crate::identifiers::Venue;
26
27static CBCM_LOCK: OnceLock<Venue> = OnceLock::new();
28static GLBX_LOCK: OnceLock<Venue> = OnceLock::new();
29static NYUM_LOCK: OnceLock<Venue> = OnceLock::new();
30static XCBT_LOCK: OnceLock<Venue> = OnceLock::new();
31static XCEC_LOCK: OnceLock<Venue> = OnceLock::new();
32static XCME_LOCK: OnceLock<Venue> = OnceLock::new();
33static XFXS_LOCK: OnceLock<Venue> = OnceLock::new();
34static XNYM_LOCK: OnceLock<Venue> = OnceLock::new();
35
36impl Venue {
37    #[allow(non_snake_case)]
38    pub fn CBCM() -> Self {
39        *CBCM_LOCK.get_or_init(|| Self::from("CBCM"))
40    }
41    #[allow(non_snake_case)]
42    pub fn GLBX() -> Self {
43        *GLBX_LOCK.get_or_init(|| Self::from("GLBX"))
44    }
45    #[allow(non_snake_case)]
46    pub fn NYUM() -> Self {
47        *NYUM_LOCK.get_or_init(|| Self::from("NYUM"))
48    }
49    #[allow(non_snake_case)]
50    pub fn XCBT() -> Self {
51        *XCBT_LOCK.get_or_init(|| Self::from("XCBT"))
52    }
53    #[allow(non_snake_case)]
54    pub fn XCEC() -> Self {
55        *XCEC_LOCK.get_or_init(|| Self::from("XCEC"))
56    }
57    #[allow(non_snake_case)]
58    pub fn XCME() -> Self {
59        *XCME_LOCK.get_or_init(|| Self::from("XCME"))
60    }
61    #[allow(non_snake_case)]
62    pub fn XFXS() -> Self {
63        *XFXS_LOCK.get_or_init(|| Self::from("XFXS"))
64    }
65    #[allow(non_snake_case)]
66    pub fn XNYM() -> Self {
67        *XNYM_LOCK.get_or_init(|| Self::from("XNYM"))
68    }
69}
70
71pub static VENUE_MAP: Lazy<Mutex<HashMap<&str, Venue>>> = Lazy::new(|| {
72    let mut map = HashMap::new();
73    map.insert(Venue::CBCM().inner().as_str(), Venue::CBCM());
74    map.insert(Venue::GLBX().inner().as_str(), Venue::GLBX());
75    map.insert(Venue::NYUM().inner().as_str(), Venue::NYUM());
76    map.insert(Venue::XCBT().inner().as_str(), Venue::XCBT());
77    map.insert(Venue::XCEC().inner().as_str(), Venue::XCEC());
78    map.insert(Venue::XCME().inner().as_str(), Venue::XCME());
79    map.insert(Venue::XFXS().inner().as_str(), Venue::XFXS());
80    map.insert(Venue::XNYM().inner().as_str(), Venue::XNYM());
81    Mutex::new(map)
82});