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