nautilus_core/lib.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//! Core foundational types and utilities for [NautilusTrader](http://nautilustrader.io).
17//!
18//! The `nautilus-core` crate is designed to be lightweight, efficient, and to provide zero-cost abstractions
19//! wherever possible. It supplies the essential building blocks used across the NautilusTrader
20//! ecosystem, including:
21//!
22//! - Time handling and atomic clock functionality.
23//! - UUID generation and management.
24//! - Mathematical functions and interpolation utilities.
25//! - Correctness validation functions.
26//! - Serialization traits and helpers.
27//! - Cross-platform environment utilities.
28//! - Abstractions over common collections.
29//!
30//! # Platform
31//!
32//! [NautilusTrader](http://nautilustrader.io) is an open-source, high-performance, production-grade
33//! algorithmic trading platform, providing quantitative traders with the ability to backtest
34//! portfolios of automated trading strategies on historical data with an event-driven engine,
35//! and also deploy those same strategies live, with no code changes.
36//!
37//! NautilusTrader's design, architecture, and implementation philosophy prioritizes software correctness and safety at the
38//! highest level, with the aim of supporting mission-critical, trading system backtesting and live deployment workloads.
39//!
40//! # Feature flags
41//!
42//! This crate provides feature flags to control source code inclusion during compilation,
43//! depending on the intended use case, i.e. whether to provide Python bindings
44//! for the [nautilus_trader](https://pypi.org/project/nautilus_trader) Python package,
45//! or as part of a Rust only build.
46//!
47//! - `ffi`: Enables the C foreign function interface (FFI) from [cbindgen](https://github.com/mozilla/cbindgen).
48//! - `python`: Enables Python bindings from [PyO3](https://pyo3.rs).
49//! - `extension-module`: Builds the crate as a Python extension module.
50
51#![warn(rustc::all)]
52#![deny(unsafe_code)]
53#![deny(unsafe_op_in_unsafe_fn)]
54#![deny(nonstandard_style)]
55#![deny(missing_debug_implementations)]
56#![deny(missing_docs)]
57#![deny(rustdoc::broken_intra_doc_links)]
58
59pub mod collections;
60pub mod consts;
61pub mod correctness;
62pub mod datetime;
63pub mod drop;
64pub mod env;
65pub mod math;
66pub mod message;
67pub mod nanos;
68
69pub mod parsing;
70pub mod paths;
71pub mod serialization;
72pub mod shared;
73pub mod time;
74pub mod uuid;
75
76#[cfg(feature = "ffi")]
77pub mod ffi;
78
79#[cfg(feature = "python")]
80pub mod python;
81
82#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))]
83compile_error!("Unsupported platform: Nautilus supports only Linux, macOS, and Windows");
84
85// Re-exports
86pub use crate::{
87 drop::CleanDrop,
88 nanos::UnixNanos,
89 shared::{SharedCell, WeakCell},
90 time::AtomicTime,
91 uuid::UUID4,
92};