plexus_core/lib.rs
1//! Hub Core - Core infrastructure for building Plexus RPC servers
2//!
3//! This crate provides:
4//! - `DynamicHub` - Dynamic routing hub for activations (implements Plexus RPC protocol)
5//! - `Activation` - Trait for implementing activations
6//! - `Handle` - Typed references to activation method results
7//!
8//! # Example
9//!
10//! ```rust,no_run
11//! use plexus_core::plexus::DynamicHub;
12//! use plexus_core::activations::echo::EchoActivation;
13//! use plexus_core::activations::health::Health;
14//! use std::sync::Arc;
15//!
16//! let hub = Arc::new(
17//! DynamicHub::new("myapp")
18//! .register(Health::new())
19//! .register(EchoActivation::new())
20//! );
21//! ```
22
23/// Crate version, populated at compile time from `CARGO_PKG_VERSION`.
24///
25/// Exposed so the `plexus-rpc` umbrella can stamp it into the
26/// `Capabilities` manifest backends embed in `_info`. See UMB-2.
27pub const VERSION: &str = env!("CARGO_PKG_VERSION");
28
29pub mod activations;
30pub mod builder;
31// RETURNS-47: the caller from the call's context — `call::caller()`,
32// `call::hop()`, `call::scope` — fail closed.
33pub mod call;
34pub mod plexus;
35pub mod plugin_system;
36pub mod request;
37// PLEXUS-45: the runtime seam — spawn, sleep, timeout, the clock — tokio and
38// std natively, the JS event loop and clock on wasm32.
39pub(crate) mod rt;
40pub mod serde_helpers;
41pub mod types;
42
43// Re-export commonly used items
44pub use builder::build_example_hub;
45#[allow(deprecated)]
46pub use plexus::{
47 Activation, AuthzDenyReason, Cardinality, ChildCapabilities, ChildRouter, DeprecationInfo,
48 DynamicHub, MethodRole, PlexusError, PLEXUS_NOTIF_METHOD,
49};
50pub use types::{Envelope, Handle, HandleParseError, HandleResolutionParams, Origin};
51
52// Re-export schemars under a stable private path so PlexusRequest derive-generated code
53// can reference the real schemars::JsonSchema trait without requiring the caller to have
54// schemars in their own dependencies.
55#[doc(hidden)]
56pub use schemars as __schemars;
57
58// Proc-macro re-exports.
59// Use as `plexus_core::activation` / `plexus_core::method`, or via a
60// `plexus = { package = "plexus-core" }` Cargo alias as `plexus::activation` / `plexus::method`.
61pub use plexus_macros::activation;
62pub use plexus_macros::method;
63#[allow(deprecated)]
64#[deprecated(since = "0.5.0", note = "Use `plexus_core::activation` instead")]
65pub use plexus_macros::hub_methods;
66#[allow(deprecated)]
67#[deprecated(since = "0.5.0", note = "Use `plexus_core::method` instead")]
68pub use plexus_macros::hub_method;