pub trait Plugin {
// Required methods
fn manifest() -> PluginManifest;
fn execute(args: Vec<String>) -> ExecuteResult;
// Provided method
fn resume(_effect_id: u32, _result: EffectResult) -> ExecuteResult { ... }
}Expand description
Trait that plugins must implement
Required Methods§
Sourcefn manifest() -> PluginManifest
fn manifest() -> PluginManifest
Returns the plugin manifest describing the command
Sourcefn execute(args: Vec<String>) -> ExecuteResult
fn execute(args: Vec<String>) -> ExecuteResult
Executes the plugin with the given arguments
Provided Methods§
Sourcefn resume(_effect_id: u32, _result: EffectResult) -> ExecuteResult
fn resume(_effect_id: u32, _result: EffectResult) -> ExecuteResult
Resume execution after an effect completes
Called by the host when an effect (HTTP request, sleep, etc.) completes. The plugin should continue its work with the effect result.
Default implementation returns an error - override if using effects.
§Arguments
effect_id- The ID of the completed effectresult- The result of the effect
§Example
ⓘ
fn resume(effect_id: u32, result: EffectResult) -> ExecuteResult {
match result {
EffectResult::Http(response) => {
if response.is_success() {
ExecuteResult::success(response.body)
} else {
ExecuteResult::user_error(format!("HTTP {}", response.status))
}
}
EffectResult::Error(e) => ExecuteResult::user_error(e),
_ => ExecuteResult::system_error("Unexpected effect result"),
}
}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.