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§
Provided Methods§
Sourcefn run(&self, cx: Context) -> impl Future<Output = ()>
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.
Sourcefn call(&self, method: &str, request: Json, cx: &Context) -> Result<Json>
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.
Sourcefn deactivate(&self)
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".