pub trait ServerPlugin:
Send
+ Sync
+ 'static {
// Required methods
fn name(&self) -> &'static str;
fn run<'life0, 'async_trait>(
&'life0 self,
ctx: PluginContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn rpc_methods(&self) -> Vec<RpcMethodDef> { ... }
}Expand description
Trait for plugins that run a single long-lived background task.
The run future should observe ctx.shutdown and return when signaled.
Required Methods§
Sourcefn name(&self) -> &'static str
fn name(&self) -> &'static str
Stable plugin name (same semantics as Plugin::name).
Sourcefn run<'life0, 'async_trait>(
&'life0 self,
ctx: PluginContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn run<'life0, 'async_trait>(
&'life0 self,
ctx: PluginContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Run the plugin’s main loop. Return Ok(()) on shutdown.
Observe ctx.shutdown to detect the server shutdown signal.
Do not discard watch::RecvError with .ok() — treat it as an
unexpected condition (the sender was dropped without signaling shutdown)
and log an error:
ⓘ
if let Err(e) = ctx.shutdown.changed().await {
tracing::error!(error = %e, "shutdown sender dropped unexpectedly");
}Provided Methods§
Sourcefn rpc_methods(&self) -> Vec<RpcMethodDef>
fn rpc_methods(&self) -> Vec<RpcMethodDef>
Optional RPC method advertisements (default empty).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".