Trait gravel_ffi::Frontend
source · pub trait Frontend {
// Required methods
fn new(
engine: BoxDynFrontendContext,
config: &PluginConfigAdapter<'_>,
) -> Self;
fn run(
&mut self,
receiver: RReceiver<FrontendMessageNe>,
) -> 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, receiver: RReceiver<FrontendMessageNe>) -> 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.
sourcefn run(&mut self, receiver: RReceiver<FrontendMessageNe>) -> FrontendExitStatus
fn run(&mut self, receiver: RReceiver<FrontendMessageNe>) -> FrontendExitStatus
Runs the UI. Messages sent to the receiver
must be handled.
Object Safety§
This trait is not object safe.