Skip to main content

DaemonPlugin

Trait DaemonPlugin 

Source
pub trait DaemonPlugin: Sized + 'static {
    // Required method
    fn activate(cx: &Context) -> Self;

    // Provided methods
    fn run(&self, cx: Context) -> impl Future<Output = ()> { ... }
    fn call(&self, method: &str, request: Json, cx: &Context) -> Result<Json> { ... }
    fn deactivate(&self) { ... }
}
Expand description

A daemon (or companion) plugin.

Required Methods§

Source

fn activate(cx: &Context) -> Self

Called once after instantiation.

Provided Methods§

Source

fn run(&self, cx: Context) -> impl Future<Output = ()>

The plugin’s long-running work, started after activate and dropped at deactivate. Await Context::next_event for events and Context::sleep between rounds of work.

Source

fn call(&self, method: &str, request: Json, cx: &Context) -> Result<Json>

Answers a call from the UI plugin with the same id. The default knows no method.

Source

fn deactivate(&self)

Called before the instance is dropped, after the run loop is.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§