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