nautilus_common/custom.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//! A user custom data type.
17
18use bytes::Bytes;
19use nautilus_core::UnixNanos;
20use nautilus_model::data::DataType;
21use serde::{Deserialize, Serialize};
22
23/// Represents a custom data.
24#[repr(C)]
25#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
26#[cfg_attr(
27 feature = "python",
28 pyo3::pyclass(module = "nautilus_trader.core.nautilus_pyo3.common")
29)]
30pub struct CustomData {
31 pub data_type: DataType,
32 pub value: Bytes,
33 pub ts_event: UnixNanos,
34 pub ts_init: UnixNanos,
35}
36
37impl CustomData {
38 /// Creates a new [`CustomData`] instance.
39 pub const fn new(
40 data_type: DataType,
41 value: Bytes,
42 ts_event: UnixNanos,
43 ts_init: UnixNanos,
44 ) -> Self {
45 Self {
46 data_type,
47 value,
48 ts_event,
49 ts_init,
50 }
51 }
52}