nautilus_common/python/
mod.rs

1// -------------------------------------------------------------------------------------------------
2//  Copyright (C) 2015-2025 Posei Systems Pty Ltd. All rights reserved.
3//  https://poseitrader.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//! Python bindings from [PyO3](https://pyo3.rs).
17
18pub mod actor;
19pub mod clock;
20pub mod custom;
21pub mod enums;
22pub mod handler;
23pub mod listener;
24pub mod logging;
25pub mod msgbus;
26pub mod signal;
27pub mod timer;
28pub mod xrate;
29
30use pyo3::prelude::*;
31
32/// Loaded as nautilus_pyo3.common
33///
34/// # Errors
35///
36/// Returns a `PyErr` if registering any module components fails.
37#[pymodule]
38pub fn common(_: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> {
39    m.add_class::<crate::custom::CustomData>()?;
40    m.add_class::<crate::signal::Signal>()?;
41    m.add_class::<crate::python::clock::TestClock_Py>()?;
42    m.add_class::<crate::python::clock::LiveClock_Py>()?;
43    m.add_class::<crate::python::actor::PyDataActor>()?;
44    m.add_class::<crate::msgbus::BusMessage>()?;
45    m.add_class::<crate::msgbus::MessageBus>()?;
46    m.add_class::<crate::msgbus::listener::MessageBusListener>()?;
47    m.add_class::<crate::python::handler::PythonMessageHandler>()?;
48    m.add_class::<crate::enums::ComponentState>()?;
49    m.add_class::<crate::enums::ComponentTrigger>()?;
50    m.add_class::<crate::enums::LogColor>()?;
51    m.add_class::<crate::enums::LogLevel>()?;
52    m.add_class::<crate::enums::LogFormat>()?;
53    m.add_class::<crate::logging::logger::LoggerConfig>()?;
54    m.add_class::<crate::logging::logger::LogGuard>()?;
55    m.add_class::<crate::logging::writer::FileWriterConfig>()?;
56    m.add_function(wrap_pyfunction!(logging::py_init_tracing, m)?)?;
57    m.add_function(wrap_pyfunction!(logging::py_init_logging, m)?)?;
58    m.add_function(wrap_pyfunction!(logging::py_logger_flush, m)?)?;
59    m.add_function(wrap_pyfunction!(logging::py_logger_log, m)?)?;
60    m.add_function(wrap_pyfunction!(logging::py_log_header, m)?)?;
61    m.add_function(wrap_pyfunction!(logging::py_log_sysinfo, m)?)?;
62    m.add_function(wrap_pyfunction!(
63        logging::py_logging_clock_set_static_mode,
64        m
65    )?)?;
66    m.add_function(wrap_pyfunction!(
67        logging::py_logging_clock_set_realtime_mode,
68        m
69    )?)?;
70    m.add_function(wrap_pyfunction!(
71        logging::py_logging_clock_set_static_time,
72        m
73    )?)?;
74    m.add_function(wrap_pyfunction!(xrate::py_get_exchange_rate, m)?)?;
75
76    Ok(())
77}