pub struct PluginContext {
pub data_dir: PathBuf,
pub extra: HashMap<String, String>,
pub config_json: Option<String>,
}Expand description
Context passed to plugins during execution Provides access to shared resources
Fields§
§data_dir: PathBufPath to the data directory
extra: HashMap<String, String>Additional context data (plugin-specific)
config_json: Option<String>Plugin configuration as JSON string (deserialized by plugin)
Implementations§
Source§impl PluginContext
impl PluginContext
pub fn new(data_dir: PathBuf) -> Self
pub fn with_extra( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
pub fn with_config(self, config_json: impl Into<String>) -> Self
Sourcepub fn get_config<T: DeserializeOwned + Default>(&self) -> T
pub fn get_config<T: DeserializeOwned + Default>(&self) -> T
Deserialize configuration from JSON Returns default if no config is set or parsing fails
Sourcepub fn try_get_config<T: DeserializeOwned>(&self) -> PluginResult<Option<T>>
pub fn try_get_config<T: DeserializeOwned>(&self) -> PluginResult<Option<T>>
Try to deserialize configuration, returning an error on failure
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PluginContext
impl RefUnwindSafe for PluginContext
impl Send for PluginContext
impl Sync for PluginContext
impl Unpin for PluginContext
impl UnwindSafe for PluginContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more