Skip to main content

nautilus_plugin/bridge/
mod.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//! Host-side bridge between the plug-in C ABI and an engine.
17//!
18//! Provides actor and strategy adapters that wrap a cdylib's vtable + handle
19//! as a `DataActor` / `Strategy` an engine can register, plus the
20//! host-side [`HostVTable`](crate::HostVTable) that routes plug-in
21//! callbacks through the engine's cache, risk, event, msgbus, and timer
22//! paths. Used by both the live node and the backtest engine via the
23//! crate's `host` feature.
24//!
25//! [plug-in roadmap]: https://github.com/nautechsystems/nautilus_trader/blob/develop/crates/plugin/README.md
26//!
27//! # Layout
28//!
29//! - [`actor`]: [`PluginActorAdapter`] for plug-in actors.
30//! - [`strategy`]: [`PluginStrategyAdapter`] for plug-in strategies.
31//! - [`controller`]: [`PluginControllerAdapter`] for plug-in controllers.
32//! - [`host`]: host-side `HostVTable` construction with engine callback routing.
33//! - [`registry`]: the per-instance opaque context the host attaches to each
34//!   plug-in instance so host callbacks can be attributed to the calling
35//!   adapter.
36//! - [`configured`]: config-resolved adapter construction from a loaded
37//!   plug-in manifest, used by engine startup code.
38//!
39//! Execution command structs and their boundary-owned handles live at
40//! [`crate::surfaces::commands`] and are re-exported below for the
41//! historical `nautilus_plugin::bridge::*` import path.
42
43#![allow(unsafe_code)]
44
45macro_rules! validated_slot {
46    ($vtable_ty:ident, $vtable:expr, $slot:ident) => {{
47        (*($vtable)).$slot.expect(concat!(
48            "loader validates ",
49            stringify!($vtable_ty),
50            "::",
51            stringify!($slot),
52        ))
53    }};
54}
55
56pub mod actor;
57pub mod controller;
58pub mod custom_data;
59pub mod host;
60pub mod registry;
61pub mod strategy;
62
63pub mod configured;
64
65pub use actor::PluginActorAdapter;
66pub use configured::{
67    ConfiguredControllerEntry, ConfiguredPluginEntry, configured_entry,
68    register_manifest_custom_data,
69};
70pub use controller::PluginControllerAdapter;
71pub use custom_data::{PluginCustomDataValue, register_custom_data_from_manifest};
72pub use host::{controller_host_vtable, host_vtable, plugin_loader};
73pub use registry::HostContextInner;
74pub use strategy::PluginStrategyAdapter;
75
76// Re-exported for backwards compatibility with the historical
77// `nautilus_plugin::bridge::*` import path. The command structs and their
78// handles live under `crate::surfaces::commands`.
79pub use crate::surfaces::commands::{
80    CancelAllOrdersCommand, CancelAllOrdersHandle, CancelOrderCommand, CancelOrderHandle,
81    CancelOrdersCommand, CancelOrdersHandle, CloseAllPositionsCommand, CloseAllPositionsHandle,
82    ClosePositionCommand, ClosePositionHandle, ModifyOrderCommand, ModifyOrderHandle,
83    QueryAccountCommand, QueryAccountHandle, QueryOrderCommand, QueryOrderHandle,
84    SubmitOrderCommand, SubmitOrderHandle, SubmitOrderListCommand, SubmitOrderListHandle,
85};