gravel_ffi

Trait Frontend

Source
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§

Source

fn new(engine: BoxDynFrontendContext, config: &PluginConfigAdapter<'_>) -> Self

Constructs a new frontend. Events must be received and handled by calling FrontendContextExt::recv.

Source

fn run(&mut self) -> FrontendExitStatus

Runs the UI; must block until ready to exit.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§