nautilus_common/python/signal.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
16use nautilus_core::UnixNanos;
17use pyo3::prelude::*;
18use ustr::Ustr;
19
20use crate::signal::Signal;
21
22#[pymethods]
23#[pyo3_stub_gen::derive::gen_stub_pymethods]
24impl Signal {
25 /// Represents a generic signal.
26 #[new]
27 fn py_new(name: &str, value: String, ts_event: u64, ts_init: u64) -> Self {
28 Self::new(
29 Ustr::from(name),
30 value,
31 UnixNanos::from(ts_event),
32 UnixNanos::from(ts_init),
33 )
34 }
35
36 #[getter]
37 #[pyo3(name = "name")]
38 fn py_name(&self) -> &str {
39 self.name.as_str()
40 }
41
42 #[getter]
43 #[pyo3(name = "value")]
44 fn py_value(&self) -> &str {
45 self.value.as_str()
46 }
47
48 #[getter]
49 #[pyo3(name = "ts_event")]
50 const fn py_ts_event(&self) -> u64 {
51 self.ts_event.as_u64()
52 }
53
54 #[getter]
55 #[pyo3(name = "ts_init")]
56 const fn py_ts_init(&self) -> u64 {
57 self.ts_init.as_u64()
58 }
59}