extension_host 0.0.2

wasm host
Documentation
use anyhow::Result;
use serde::{Deserialize, Serialize};
use std::path::Path;

#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
pub struct PluginManifest {
    pub id: String,
    pub name: String,
    pub version: String,
    #[serde(default)]
    pub description: Option<String>,
    #[serde(default)]
    pub repository: Option<String>,
    #[serde(default)]
    pub authors: Vec<String>,
    #[serde(default)]
    pub schema_version: Option<String>,
}

impl PluginManifest {
    pub fn new(
        id: String,
        name: String,
        version: String,
        description: Option<String>,
        authors: Vec<String>,
        repository: Option<String>,
        schema_version: Option<String>,
    ) -> Self {
        Self {
            id,
            name,
            version,
            description,
            repository,
            authors,
            schema_version,
        }
    }

    pub async fn load(wasm_path: &Path) -> Result<Self> {
        if !wasm_path.exists() {
            async_fs::create_dir_all(wasm_path).await?;
        }
        todo!()
        // serde_json::from_slice::<PluginManifest>(&json_bytes.as_slice())
        //     .map_err(|e| anyhow::anyhow!(e))
    }
}