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:
whisker.rsbuilds the Config struct, thenwhisker-cliserializes the resultingConfig(including this Config nested underplugins[NAME]) to JSON via the config probe.- 3rd-party plugins are subprocesses — their config arrives as
JSON in the
PluginRequestenvelope. - 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§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".