pub struct DynamicHub { /* private fields */ }Expand description
DynamicHub - an activation that routes to dynamically registered child activations
Unlike hub activations with hardcoded children (like Solar),
DynamicHub allows registering activations at runtime via .register().
§Direct Hosting
For a single activation, host it directly:
let solar = Arc::new(Solar::new());
TransportServer::builder(solar, converter).serve().await?;§Composition
For multiple top-level activations, use DynamicHub:
let hub = DynamicHub::with_namespace("myapp")
.register(Solar::new())
.register(Echo::new());Implementations§
Source§impl DynamicHub
impl DynamicHub
Sourcepub fn new(namespace: impl Into<String>) -> Self
pub fn new(namespace: impl Into<String>) -> Self
Create a new DynamicHub with explicit namespace
Unlike single activations which have fixed namespaces, DynamicHub is a composition tool that can be named based on your application. Common choices:
- “hub” - generic default
- “substrate” - for substrate server
- “myapp” - for your application name
The namespace appears in method calls: {namespace}.call, {namespace}.schema
Sourcepub fn with_namespace(namespace: impl Into<String>) -> Self
👎Deprecated since 0.3.0: Use DynamicHub::new(namespace) instead
pub fn with_namespace(namespace: impl Into<String>) -> Self
Deprecated: Use new() with explicit namespace instead
Sourcepub fn runtime_namespace(&self) -> &str
pub fn runtime_namespace(&self) -> &str
Get the runtime namespace for this DynamicHub instance
Sourcepub fn registry(&self) -> RwLockReadGuard<'_, PluginRegistry>
pub fn registry(&self) -> RwLockReadGuard<'_, PluginRegistry>
Get access to the activation registry
Sourcepub fn register<A: Activation + Clone>(self, activation: A) -> Self
pub fn register<A: Activation + Clone>(self, activation: A) -> Self
Register an activation
Sourcepub fn register_hub<A: Activation + ChildRouter + Clone + 'static>(
self,
activation: A,
) -> Self
pub fn register_hub<A: Activation + ChildRouter + Clone + 'static>( self, activation: A, ) -> Self
Register a hub activation that supports nested routing
Hub activations implement ChildRouter, enabling direct nested method calls
like hub.solar.mercury.info at the RPC layer (no hub.call indirection).
Sourcepub fn list_methods(&self) -> Vec<String>
pub fn list_methods(&self) -> Vec<String>
List all methods across all activations
Sourcepub fn list_activations_info(&self) -> Vec<ActivationInfo>
pub fn list_activations_info(&self) -> Vec<ActivationInfo>
List all activations (including this hub itself)
Sourcepub fn compute_hash(&self) -> String
pub fn compute_hash(&self) -> String
Compute hash for cache invalidation
Returns the hash from the recursive plugin schema. This hash changes whenever any method definition or child plugin changes.
Sourcepub async fn route(
&self,
method: &str,
params: Value,
) -> Result<PlexusStream, PlexusError>
pub async fn route( &self, method: &str, params: Value, ) -> Result<PlexusStream, PlexusError>
Route a call to the appropriate activation
Sourcepub async fn do_resolve_handle(
&self,
handle: &Handle,
) -> Result<PlexusStream, PlexusError>
pub async fn do_resolve_handle( &self, handle: &Handle, ) -> Result<PlexusStream, PlexusError>
Resolve a handle using the activation registry
Looks up the activation by its UUID in the registry.
Sourcepub fn get_activation_schema(&self, namespace: &str) -> Option<Schema>
pub fn get_activation_schema(&self, namespace: &str) -> Option<Schema>
Get activation schema
Sourcepub fn registry_snapshot(&self) -> PluginRegistrySnapshot
pub fn registry_snapshot(&self) -> PluginRegistrySnapshot
Get a snapshot of the activation registry (safe to use outside locks)
Sourcepub fn lookup_plugin(&self, id: Uuid) -> Option<String>
pub fn lookup_plugin(&self, id: Uuid) -> Option<String>
Look up an activation path by its UUID
Sourcepub fn lookup_plugin_by_path(&self, path: &str) -> Option<Uuid>
pub fn lookup_plugin_by_path(&self, path: &str) -> Option<Uuid>
Look up an activation UUID by its path
Sourcepub fn list_plugin_schemas(&self) -> Vec<PluginSchema>
pub fn list_plugin_schemas(&self) -> Vec<PluginSchema>
Get activation schemas for all activations (including this hub itself)
Sourcepub fn list_full_schemas(&self) -> Vec<PluginSchema>
👎Deprecated: Use list_plugin_schemas instead
pub fn list_full_schemas(&self) -> Vec<PluginSchema>
Deprecated: use list_plugin_schemas instead
Sourcepub fn get_method_help(&self, method: &str) -> Option<String>
pub fn get_method_help(&self, method: &str) -> Option<String>
Get help for a method
Sourcepub fn plugin_children(&self) -> Vec<ChildSummary>
pub fn plugin_children(&self) -> Vec<ChildSummary>
Get child activation summaries (for hub functionality)
Called by hub-macro when hub flag is set
Sourcepub fn into_rpc_module(self) -> Result<RpcModule<()>, RegisterMethodError>
pub fn into_rpc_module(self) -> Result<RpcModule<()>, RegisterMethodError>
Convert to RPC module
Sourcepub fn arc_into_rpc_module(
hub: Arc<Self>,
) -> Result<RpcModule<()>, RegisterMethodError>
pub fn arc_into_rpc_module( hub: Arc<Self>, ) -> Result<RpcModule<()>, RegisterMethodError>
Convert Arc
Unlike into_rpc_module, this keeps the Arc
Trait Implementations§
Source§impl Activation for DynamicHub
impl Activation for DynamicHub
type Methods = DynamicHubMethod
fn namespace(&self) -> &str
fn version(&self) -> &str
Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§fn long_description(&self) -> Option<&str>
fn long_description(&self) -> Option<&str>
fn methods(&self) -> Vec<&str>
fn method_help(&self, method: &str) -> Option<String>
fn call<'life0, 'life1, 'async_trait>(
&'life0 self,
method: &'life1 str,
params: Value,
) -> Pin<Box<dyn Future<Output = Result<PlexusStream, PlexusError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn into_rpc_methods(self) -> Methods
Source§fn plugin_schema(&self) -> PluginSchema
fn plugin_schema(&self) -> PluginSchema
Source§fn plugin_id(&self) -> Uuid
fn plugin_id(&self) -> Uuid
fn resolve_handle<'life0, 'life1, 'async_trait>(
&'life0 self,
_handle: &'life1 Handle,
) -> Pin<Box<dyn Future<Output = Result<PlexusStream, PlexusError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§impl ChildRouter for DynamicHub
ChildRouter implementation for DynamicHub
impl ChildRouter for DynamicHub
ChildRouter implementation for DynamicHub
This enables nested routing through registered activations. e.g., hub.call(“solar.mercury.info”) routes to solar → mercury → info
Source§fn router_namespace(&self) -> &str
fn router_namespace(&self) -> &str
Source§fn router_call<'life0, 'life1, 'async_trait>(
&'life0 self,
method: &'life1 str,
params: Value,
) -> Pin<Box<dyn Future<Output = Result<PlexusStream, PlexusError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn router_call<'life0, 'life1, 'async_trait>(
&'life0 self,
method: &'life1 str,
params: Value,
) -> Pin<Box<dyn Future<Output = Result<PlexusStream, PlexusError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§impl Clone for DynamicHub
impl Clone for DynamicHub
Source§fn clone(&self) -> DynamicHub
fn clone(&self) -> DynamicHub
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more