Skip to main content

PluginContext

Trait PluginContext 

Source
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§

Source

fn db(&self) -> &dyn DatabaseAccess

Sandboxed database access (own tables + approved host tables).

Source

fn events(&self) -> &dyn EventBus

App event bus.

Source

fn http(&self) -> Option<&dyn HttpClient>

HTTP client — None if network:http* not granted.

Source

fn fs(&self) -> Option<&dyn PluginFs>

Filesystem access — None if filesystem:* not granted.

Source

fn process(&self) -> Option<&dyn ProcessRunner>

Process runner — None if process:spawn* not granted.

Source

fn settings(&self) -> Value

Read the plugin’s current settings (values from settings_schema).

Source

fn save_settings(&self, settings: Value) -> Result<(), PluginError>

Persist updated plugin settings.

Source

fn data_dir(&self) -> PathBuf

Absolute path to the plugin’s private data directory. e.g. ~/.haloforge/plugins/{plugin-id}/data/

Source

fn log(&self, level: LogLevel, msg: &str)

Emit a structured log line tagged with the plugin id.

Source

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".

Implementors§