pub trait PluginFactory:
Send
+ Sync
+ 'static {
// Required method
fn create(&self, config: JsonValue) -> Result<Box<dyn Plugin>>;
}Expand description
Constructs a Plugin from runtime configuration.
Required Methods§
Sourcefn create(&self, config: JsonValue) -> Result<Box<dyn Plugin>>
fn create(&self, config: JsonValue) -> Result<Box<dyn Plugin>>
Construct a plugin from its config section (JSON from folk.toml).
§Contract: empty config must be accepted
folk-builder compiles every selected plugin into the extension
unconditionally and passes {} (an empty JSON object) for any plugin
whose section is absent from folk.toml. Implementations must
succeed on create(json!({})) and apply sensible defaults — an absent
section is not the same as a disabled plugin.
Every plugin crate should include a regression test:
ⓘ
#[test]
fn factory_accepts_empty_config() {
assert!(folk_plugin_factory().create(serde_json::json!({})).is_ok());
}Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".