nautilus_plugin/lib.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
16//! Plug-in artifact identity and boundary primitives for NautilusTrader.
17//!
18//! This crate provides the public contract that lets an independently compiled
19//! Rust cdylib identify itself to a Nautilus host. It defines versioned build
20//! metadata, allocator-safe boundary values, opaque host tokens, and the
21//! `nautilus_plugin!` macro for exporting the standard entry symbol and
22//! manifest.
23
24#![warn(clippy::pedantic)]
25#![allow(
26 clippy::assert_is_empty,
27 reason = "`assert!(x.is_empty())` is clearer than comparing against an empty value"
28)]
29
30/// ABI version of the public plug-in metadata contract.
31///
32/// The host refuses to load a plug-in whose
33/// [`PluginManifest::abi_version`](crate::manifest::PluginManifest::abi_version)
34/// does not match this value.
35pub const NAUTILUS_PLUGIN_ABI_VERSION: u32 = 1;
36
37/// Schema version for [`manifest::PluginBuildId`].
38pub const PLUGIN_BUILD_ID_VERSION: u32 = 1;
39
40/// Name of the single `extern "C"` entry symbol every plug-in cdylib exports.
41pub const NAUTILUS_PLUGIN_INIT_SYMBOL: &[u8] = b"nautilus_plugin_init";
42
43pub mod boundary;
44pub mod host;
45pub mod manifest;
46pub mod panic;
47
48mod macros;
49
50pub use boundary::{BorrowedStr, OwnedBytes, PluginError, PluginErrorCode, PluginResult, Slice};
51pub use host::{HostContext, HostVTable};
52pub use manifest::{PluginBuildId, PluginInitFn, PluginManifest};
53
54/// Re-exports that plug-in crates typically want in scope.
55pub mod prelude {
56 pub use crate::{
57 BorrowedStr, HostContext, HostVTable, NAUTILUS_PLUGIN_ABI_VERSION, PluginBuildId,
58 PluginError, PluginErrorCode, PluginManifest, PluginResult, Slice,
59 };
60}
61
62#[cfg(test)]
63mod tests {
64 use rstest::rstest;
65
66 use super::*;
67
68 #[rstest]
69 fn init_symbol_matches_exported_entrypoint() {
70 assert_eq!(NAUTILUS_PLUGIN_INIT_SYMBOL, b"nautilus_plugin_init");
71 }
72}