pub trait PluginContext: Send + Sync {
// Required methods
fn db(&self) -> &dyn DatabaseAccess;
fn events(&self) -> &dyn EventBus;
fn http(&self) -> Option<&dyn HttpClient>;
fn fs(&self) -> Option<&dyn PluginFs>;
fn process(&self) -> Option<&dyn ProcessRunner>;
fn settings(&self) -> Value;
fn save_settings(&self, settings: Value) -> Result<(), PluginError>;
fn data_dir(&self) -> PathBuf;
fn log(&self, level: LogLevel, msg: &str);
fn notify(&self, notification: Notification);
}Expand description
The host-provided context injected into the plugin at load time. This is the plugin’s only gateway to host services.
Required Methods§
Sourcefn db(&self) -> &dyn DatabaseAccess
fn db(&self) -> &dyn DatabaseAccess
Sandboxed database access (own tables + approved host tables).
Sourcefn http(&self) -> Option<&dyn HttpClient>
fn http(&self) -> Option<&dyn HttpClient>
HTTP client — None if network:http* not granted.
Sourcefn process(&self) -> Option<&dyn ProcessRunner>
fn process(&self) -> Option<&dyn ProcessRunner>
Process runner — None if process:spawn* not granted.
Sourcefn save_settings(&self, settings: Value) -> Result<(), PluginError>
fn save_settings(&self, settings: Value) -> Result<(), PluginError>
Persist updated plugin settings.
Sourcefn data_dir(&self) -> PathBuf
fn data_dir(&self) -> PathBuf
Absolute path to the plugin’s private data directory.
e.g. ~/.haloforge/plugins/{plugin-id}/data/
Sourcefn log(&self, level: LogLevel, msg: &str)
fn log(&self, level: LogLevel, msg: &str)
Emit a structured log line tagged with the plugin id.
Sourcefn notify(&self, notification: Notification)
fn notify(&self, notification: Notification)
Show a toast notification in the HaloForge UI.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".