Skip to main content

ProtocolPlugin

Trait ProtocolPlugin 

Source
pub trait ProtocolPlugin: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn alpn(&self) -> Option<Vec<u8>>;
    fn on_runtime_ready<'life0, 'async_trait>(
        &'life0 self,
        context: RuntimeContext,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn kind(&self) -> ProtocolPluginKind { ... }
    fn router_handler(&self) -> Option<Box<dyn DynProtocolHandler>> { ... }
    fn has_router_handler(&self) -> bool { ... }
    fn readiness(&self) -> ProtocolPluginReadiness { ... }
    fn descriptor(&self) -> ProtocolPluginDescriptor { ... }
}

Required Methods§

Source

fn name(&self) -> &'static str

Source

fn alpn(&self) -> Option<Vec<u8>>

Source

fn on_runtime_ready<'life0, 'async_trait>( &'life0 self, context: RuntimeContext, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Provided Methods§

Source

fn kind(&self) -> ProtocolPluginKind

Delegation rule:

  • Rust owns protocol registration and runtime lifecycle
  • plugins describe how they integrate with the runtime, but they do not become a second lifecycle engine
Source

fn router_handler(&self) -> Option<Box<dyn DynProtocolHandler>>

Optional native router handler.

Plugins that return a handler here can be wired directly into an iroh RouterBuilder through ProtocolRegistry::apply_router_handlers(). Session-adjacent plugins should leave this as None.

Source

fn has_router_handler(&self) -> bool

Source

fn readiness(&self) -> ProtocolPluginReadiness

Source

fn descriptor(&self) -> ProtocolPluginDescriptor

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§