use alloc::string::String;
use alloc::vec::Vec;
use serde::{Serialize, Deserialize};
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ModuleManifest {
pub name: String,
pub version: String,
pub author: Option<String>,
pub description: Option<String>,
pub built_at: Option<String>,
pub dependencies: Vec<Dependency>,
pub stack_size: Option<u32>,
pub ram_size: Option<u32>,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Dependency {
pub name: String,
pub min_version: String,
pub max_version: Option<String>,
}
impl ModuleManifest {
#[cfg(feature = "std")]
pub fn to_toml(&self) -> Result<String, toml::ser::Error> {
toml::to_string_pretty(self)
}
#[cfg(feature = "std")]
pub fn from_toml(s: &str) -> Result<Self, toml::de::Error> {
toml::from_str(s)
}
pub fn to_json(&self) -> Result<String, serde_json::Error> {
serde_json::to_string_pretty(self)
}
pub fn from_json(s: &str) -> Result<Self, serde_json::Error> {
serde_json::from_str(s)
}
}