pinakes-plugin-api: update manifest, types, and wasm interface

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Ic574cc8d1d24967a8c997a3092037e526a6a6964
This commit is contained in:
raf 2026-03-08 00:42:25 +03:00
commit c8425a4c34
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
4 changed files with 53 additions and 17 deletions

View file

@ -34,7 +34,7 @@ pub struct PluginInfo {
pub homepage: Option<String>,
pub license: Option<String>,
/// Plugin kind(s) - e.g., ["media_type", "metadata_extractor"]
/// Plugin kind(s) - e.g., `media_type`, `metadata_extractor`
pub kind: Vec<String>,
/// Binary configuration
@ -95,6 +95,12 @@ pub enum ManifestError {
impl PluginManifest {
/// Load and parse a plugin manifest from a TOML file
///
/// # Errors
///
/// Returns [`ManifestError::IoError`] if the file cannot be read,
/// [`ManifestError::ParseError`] if the TOML is invalid, or
/// [`ManifestError::ValidationError`] if the manifest fails validation.
pub fn from_file(path: &Path) -> Result<Self, ManifestError> {
let content = std::fs::read_to_string(path)?;
let manifest: Self = toml::from_str(&content)?;
@ -103,6 +109,11 @@ impl PluginManifest {
}
/// Parse a manifest from TOML string
///
/// # Errors
///
/// Returns [`ManifestError::ParseError`] if the TOML is invalid, or
/// [`ManifestError::ValidationError`] if the manifest fails validation.
pub fn parse_str(content: &str) -> Result<Self, ManifestError> {
let manifest: Self = toml::from_str(content)?;
manifest.validate()?;
@ -110,6 +121,11 @@ impl PluginManifest {
}
/// Validate the manifest
///
/// # Errors
///
/// Returns [`ManifestError::ValidationError`] if any required field is empty
/// or otherwise invalid.
pub fn validate(&self) -> Result<(), ManifestError> {
// Check API version format
if self.plugin.api_version.is_empty() {
@ -163,6 +179,7 @@ impl PluginManifest {
}
/// Convert manifest capabilities to API capabilities
#[must_use]
pub fn to_capabilities(&self) -> Capabilities {
Capabilities {
filesystem: FilesystemCapability {
@ -171,14 +188,14 @@ impl PluginManifest {
.filesystem
.read
.iter()
.map(|s| s.into())
.map(std::convert::Into::into)
.collect(),
write: self
.capabilities
.filesystem
.write
.iter()
.map(|s| s.into())
.map(std::convert::Into::into)
.collect(),
},
network: NetworkCapability {
@ -201,6 +218,7 @@ impl PluginManifest {
}
/// Get plugin ID (derived from name and version)
#[must_use]
pub fn plugin_id(&self) -> String {
format!("{}@{}", self.plugin.name, self.plugin.version)
}