pub trait Frontend {
// Required methods
fn new(
engine: BoxDynFrontendContext,
config: &PluginConfigAdapter<'_>,
) -> Self;
fn run(&mut self) -> FrontendExitStatus;
}
Expand description
Abstracts functionality required for a frontend.
Implement this and add the crate::gravel_frontend
macro to write a frontend plugin:
use gravel_ffi::prelude::*;
pub struct MyFrontend {
// put state here
}
// give the plugin a memorable name
#[gravel_frontend("my_frontend")]
impl Frontend for MyFrontend {
fn new(context: BoxDynFrontendContext, config: &PluginConfigAdapter<'_>) -> Self {
// initialize UI here
Self { }
}
fn run(&mut self) -> FrontendExitStatus {
// run UI here
// gravel will exit when this function returns
FrontendExitStatus::Exit
}
}
Required Methods§
sourcefn new(engine: BoxDynFrontendContext, config: &PluginConfigAdapter<'_>) -> Self
fn new(engine: BoxDynFrontendContext, config: &PluginConfigAdapter<'_>) -> Self
Constructs a new frontend. Events must be received and handled by calling FrontendContextExt::recv
.
sourcefn run(&mut self) -> FrontendExitStatus
fn run(&mut self) -> FrontendExitStatus
Runs the UI; must block until ready to exit.
Object Safety§
This trait is not object safe.