Skip to main content

Plugin

Trait Plugin 

Source
pub trait Plugin: Sized {
    // Required method
    fn build(self, app: &mut App);

    // Provided methods
    fn name(&self) -> &'static str { ... }
    fn depends_on(&self) -> &'static [&'static str] { ... }
    fn cleanup(&mut self, _app: &mut App) { ... }
}
Expand description

Plugin trait registered via App::add_plugin.

build consumes self so the implementor can move non-clone payloads (text shapers, async runtimes, sockets) into the world.

Required Methods§

Source

fn build(self, app: &mut App)

Registers systems and resources on app, consuming the plugin.

Provided Methods§

Source

fn name(&self) -> &'static str

Returns the plugin’s name for diagnostics; defaults to the type name.

Source

fn depends_on(&self) -> &'static [&'static str]

Returns the list of plugin names this plugin depends on. Default: empty.

App::add_plugin checks each name against the already-installed set and prints a warning for any name it does not find, then builds the plugin anyway. Ordering is the caller’s responsibility; the topological sort over a deferred plugin queue is not written yet.

Source

fn cleanup(&mut self, _app: &mut App)

Optional teardown hook. Default no-op.

The intent is for async-tokio to join workers here and for render backends to release GPU resources. App has no Drop impl and nothing calls this yet, so implementing it has no effect today.

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§