pub struct MessagingPlugin { /* private fields */ }Expand description
Daemon plugin shell.
The daemon constructs the MessagingService first (since its RPC
layer needs a direct handle to call send, mark_*, history, etc.)
and then wraps it with this plugin so payload dispatch and lifecycle
hooks can flow through the same instance.
Implementations§
Source§impl MessagingPlugin
impl MessagingPlugin
Sourcepub fn new(service: Arc<MessagingService>) -> Arc<Self>
pub fn new(service: Arc<MessagingService>) -> Arc<Self>
Wrap an existing MessagingService as a DaemonPlugin.
Trait Implementations§
Source§impl DaemonPlugin for MessagingPlugin
impl DaemonPlugin for MessagingPlugin
Source§fn name(&self) -> &'static str
fn name(&self) -> &'static str
Stable identifier — used for log spans and (by convention) as a
prefix for the plugin’s payload kinds.
Source§fn payload_kinds(&self) -> &'static [&'static str]
fn payload_kinds(&self) -> &'static [&'static str]
Stable list of
PluginPayload.kind values this plugin claims.
The daemon dispatches inbound payloads by matching kind
against each registered plugin in order; the first match wins.Source§fn handle_payload<'life0, 'life1, 'async_trait>(
&'life0 self,
src: NodeId,
kind: &'life1 str,
body: Bytes,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn handle_payload<'life0, 'life1, 'async_trait>(
&'life0 self,
src: NodeId,
kind: &'life1 str,
body: Bytes,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn start<'async_trait>(
self: Arc<Self>,
_ctx: PluginContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
fn start<'async_trait>(
self: Arc<Self>,
_ctx: PluginContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
Spawn whatever long-running tasks the plugin needs. Returns
once startup is complete; long-running work should be on
detached
tokio::spawn handles tied to ctx.cancel.Source§fn on_peer_forgotten<'life0, 'async_trait>(
&'life0 self,
peer: NodeId,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_peer_forgotten<'life0, 'async_trait>(
&'life0 self,
peer: NodeId,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Notification: the daemon dropped this peer’s identity from the
keystore (e.g. via
peers.forget). Plugins typically wipe any
per-peer state of their own here. Failure is logged but does
not block other plugins from being notified.Auto Trait Implementations§
impl Freeze for MessagingPlugin
impl !RefUnwindSafe for MessagingPlugin
impl Send for MessagingPlugin
impl Sync for MessagingPlugin
impl Unpin for MessagingPlugin
impl UnsafeUnpin for MessagingPlugin
impl !UnwindSafe for MessagingPlugin
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more