Skip to main content

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;
31pub mod plexus;
32pub mod plugin_system;
33pub mod request;
34pub mod serde_helpers;
35pub mod types;
36
37// Re-export commonly used items
38pub use builder::build_example_hub;
39#[allow(deprecated)]
40pub use plexus::{
41    Activation, AuthzDenyReason, Cardinality, ChildCapabilities, ChildRouter, DeprecationInfo,
42    DynamicHub, MethodRole, PlexusError, PLEXUS_NOTIF_METHOD,
43};
44pub use types::{Envelope, Handle, HandleParseError, HandleResolutionParams, Origin};
45
46// Re-export schemars under a stable private path so PlexusRequest derive-generated code
47// can reference the real schemars::JsonSchema trait without requiring the caller to have
48// schemars in their own dependencies.
49#[doc(hidden)]
50pub use schemars as __schemars;
51
52// Proc-macro re-exports.
53// Use as `plexus_core::activation` / `plexus_core::method`, or via a
54// `plexus = { package = "plexus-core" }` Cargo alias as `plexus::activation` / `plexus::method`.
55pub use plexus_macros::activation;
56pub use plexus_macros::method;
57#[allow(deprecated)]
58#[deprecated(since = "0.5.0", note = "Use `plexus_core::activation` instead")]
59pub use plexus_macros::hub_methods;
60#[allow(deprecated)]
61#[deprecated(since = "0.5.0", note = "Use `plexus_core::method` instead")]
62pub use plexus_macros::hub_method;