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