Skip to main content

PluginConfig

Trait PluginConfig 

Source
pub trait PluginConfig:
    Serialize
    + for<'de> Deserialize<'de>
    + Default {
    const NAME: &'static str;
}
Expand description

Trait implemented by the typed config struct each plugin defines.

Carries the plugin’s stable kebab-case identifier as a const so the app.plugin::<MyPlugin>(|c| ...) builder in whisker-config can resolve the storage key via <MyPlugin as Plugin>::Config::NAME.

§Why Serialize + DeserializeOwned

Three reasons, all wire-related:

  1. whisker.rs builds the Config struct, then whisker-cli serializes the resulting Config (including this Config nested under plugins[NAME]) to JSON via the config probe.
  2. 3rd-party plugins are subprocesses — their config arrives as JSON in the PluginRequest envelope.
  3. The mutation journal records the config that produced each mutation, so we can attribute “plugin X with config Y” in error messages.

§Why Default

app.plugin::<MyPlugin>(|c| ...) starts from Config::default() and lets the closure mutate it. A user who declares a plugin without touching any options should still get a working config — the call site reads as app.plugin::<MyPlugin>(|_| {}).

§Convention for NAME

Kebab-case; prefix 1st-party plugins with whisker- (e.g. whisker-info-plist, whisker-permissions). The default Plugin::name implementation returns this value, so under normal use the plugin’s name and its Config’s NAME are the same string by construction.

Required Associated Constants§

Source

const NAME: &'static str

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§