Skip to main content

HubContext

Trait HubContext 

Source
pub trait HubContext:
    Clone
    + Send
    + Sync
    + 'static {
    // Required methods
    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;
    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;

    // Provided method
    fn is_valid(&self) -> bool { ... }
}
Expand description

Trait for parent context that can be injected into child plugins.

This trait defines the capabilities a child plugin expects from its parent. Any hub that wants to inject context into children should implement this trait (or provide a type that implements it).

The trait is object-safe to allow dynamic dispatch when needed, though most usage will be through generic bounds.

Required Methods§

Source

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,

Resolve a handle through the parent’s plugin registry.

This allows children to resolve handles from sibling plugins without knowing about them directly - they just ask the parent to route it.

Source

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,

Route a method call through the parent.

Enables children to call methods on sibling plugins via the parent hub.

Provided Methods§

Source

fn is_valid(&self) -> bool

Check if the parent context is still valid.

For weak references, this checks if the parent is still alive. For strong references or owned contexts, this always returns true.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl HubContext for Weak<DynamicHub>

HubContext implementation for Weak

This enables activations to receive a weak reference to their parent DynamicHub, allowing them to resolve handles and route calls through the hub without creating reference cycles.

Source§

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§

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,

Source§

fn is_valid(&self) -> bool

Implementors§