pub struct PluginInitContext<'a> { /* private fields */ }Implementations§
Source§impl<'a> PluginInitContext<'a>
impl<'a> PluginInitContext<'a>
pub fn credentials(&self) -> CredentialsHandle
Sourcepub fn config<C: DeserializeOwned>(&self) -> Result<C, String>
pub fn config<C: DeserializeOwned>(&self) -> Result<C, String>
Deserializes the raw JSON configuration into the plugin’s requested config struct.
Note on Serde Configuration Defaults:
This performs strict structural deserialization. If the JSON object provided by the
ConfigProvider is missing a field that your Rust struct (which must derive Deserialize) expects, serde will
return a missing field error — even if your struct implements Default.
To make a configuration field optional, use the #[serde(default)]
attribute on the struct field. This instructs serde to fall back to Default::default()
when the key is omitted.
Sourcepub fn optional_config<C: DeserializeOwned>(&self) -> Result<Option<C>, String>
pub fn optional_config<C: DeserializeOwned>(&self) -> Result<Option<C>, String>
Extracts the configuration if present, or returns None if the configuration is completely empty or null.
This allows plugins to have a mandatory configuration schema when provided, but remain optional overall.
Sourcepub async fn store<S: StorageConnection>(&self) -> Result<Arc<S>, String>
pub async fn store<S: StorageConnection>(&self) -> Result<Arc<S>, String>
Initializes and returns a shared database connection scoped strictly to this plugin’s namespace.