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