speck-core 0.2.0

Secure runtime package manager for MMU-less microcontrollers
Documentation
//! Module manifest for metadata and dependencies

use alloc::string::String;
use alloc::vec::Vec;
use serde::{Serialize, Deserialize};

/// Module metadata manifest
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ModuleManifest {
    /// Human-readable name
    pub name: String,
    
    /// Semantic version string
    pub version: String,
    
    /// Author or vendor
    pub author: Option<String>,
    
    /// Description
    pub description: Option<String>,
    
    /// Build timestamp (ISO 8601)
    pub built_at: Option<String>,
    
    /// Required dependencies (module name -> min version)
    pub dependencies: Vec<Dependency>,
    
    /// Maximum stack usage (bytes)
    pub stack_size: Option<u32>,
    
    /// Static RAM requirement (bytes)
    pub ram_size: Option<u32>,
}

/// Dependency specification
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Dependency {
    /// Module name
    pub name: String,
    /// Minimum required version
    pub min_version: String,
    /// Maximum compatible version (exclusive)
    pub max_version: Option<String>,
}

impl ModuleManifest {
    /// Serialize to TOML bytes
    #[cfg(feature = "std")]
    pub fn to_toml(&self) -> Result<String, toml::ser::Error> {
        toml::to_string_pretty(self)
    }
    
    /// Deserialize from TOML
    #[cfg(feature = "std")]
    pub fn from_toml(s: &str) -> Result<Self, toml::de::Error> {
        toml::from_str(s)
    }
    
    /// Serialize to JSON bytes
    pub fn to_json(&self) -> Result<String, serde_json::Error> {
        serde_json::to_string_pretty(self)
    }
    
    /// Deserialize from JSON
    pub fn from_json(s: &str) -> Result<Self, serde_json::Error> {
        serde_json::from_str(s)
    }
}