Skip to main content

nautilus_common/python/
mod.rs

1// -------------------------------------------------------------------------------------------------
2//  Copyright (C) 2015-2026 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//! Python bindings from [PyO3](https://pyo3.rs).
17
18pub mod actor;
19pub mod cache;
20pub mod clock;
21pub mod custom;
22pub mod enums;
23pub mod fifo;
24pub mod listener;
25pub mod logging;
26pub mod msgbus;
27pub mod runtime;
28pub mod signal;
29pub mod timer;
30pub mod xrate;
31
32use pyo3::prelude::*;
33
34/// Loaded as `nautilus_pyo3.common`.
35///
36/// # Errors
37///
38/// Returns a `PyErr` if registering any module components fails.
39#[rustfmt::skip]
40#[pymodule]
41pub fn common(_: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> {
42    m.add_class::<crate::custom::CustomData>()?;
43    m.add_class::<crate::signal::Signal>()?;
44    m.add_class::<crate::cache::CacheConfig>()?;
45    m.add_class::<crate::cache::Cache>()?;
46    m.add_class::<crate::python::actor::PyDataActor>()?;
47    m.add_class::<crate::python::cache::PyCache>()?;
48    m.add_class::<crate::python::fifo::PyFifoCache>()?;
49    m.add_class::<crate::python::clock::PyClock>()?;
50    m.add_class::<crate::python::logging::PyLogger>()?;
51    m.add_class::<crate::actor::data_actor::DataActorConfig>()?;
52    m.add_class::<crate::actor::data_actor::ImportableActorConfig>()?;
53    m.add_class::<crate::msgbus::BusMessage>()?;
54    m.add_class::<crate::enums::ComponentState>()?;
55    m.add_class::<crate::enums::ComponentTrigger>()?;
56    m.add_class::<crate::enums::Environment>()?;
57    m.add_class::<crate::enums::LogColor>()?;
58    m.add_class::<crate::enums::LogLevel>()?;
59    m.add_class::<crate::enums::LogFormat>()?;
60    m.add_class::<crate::logging::logger::LoggerConfig>()?;
61    m.add_class::<crate::logging::logger::LogGuard>()?;
62    m.add_class::<crate::logging::writer::FileWriterConfig>()?;
63    m.add_function(wrap_pyfunction!(logging::py_init_logging, m)?)?;
64    m.add_function(wrap_pyfunction!(logging::py_logger_flush, m)?)?;
65    m.add_function(wrap_pyfunction!(logging::py_logger_log, m)?)?;
66    m.add_function(wrap_pyfunction!(logging::py_log_header, m)?)?;
67    m.add_function(wrap_pyfunction!(logging::py_log_sysinfo, m)?)?;
68    m.add_function(wrap_pyfunction!(logging::py_logging_clock_set_static_mode, m)?)?;
69    m.add_function(wrap_pyfunction!(logging::py_logging_clock_set_realtime_mode, m)?)?;
70    m.add_function(wrap_pyfunction!(logging::py_logging_clock_set_static_time, m)?)?;
71    #[cfg(feature = "tracing-bridge")]
72    m.add_function(wrap_pyfunction!(logging::py_tracing_is_initialized, m)?)?;
73    #[cfg(feature = "tracing-bridge")]
74    m.add_function(wrap_pyfunction!(logging::py_init_tracing, m)?)?;
75    m.add_function(wrap_pyfunction!(xrate::py_get_exchange_rate, m)?)?;
76
77    #[cfg(feature = "live")]
78    m.add_class::<crate::live::listener::MessageBusListener>()?;
79
80    Ok(())
81}