speck_core/format/
manifest.rs1use alloc::string::String;
4use alloc::vec::Vec;
5use serde::{Serialize, Deserialize};
6
7#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
9pub struct ModuleManifest {
10 pub name: String,
12
13 pub version: String,
15
16 pub author: Option<String>,
18
19 pub description: Option<String>,
21
22 pub built_at: Option<String>,
24
25 pub dependencies: Vec<Dependency>,
27
28 pub stack_size: Option<u32>,
30
31 pub ram_size: Option<u32>,
33}
34
35#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
37pub struct Dependency {
38 pub name: String,
40 pub min_version: String,
42 pub max_version: Option<String>,
44}
45
46impl ModuleManifest {
47 #[cfg(feature = "std")]
49 pub fn to_toml(&self) -> Result<String, toml::ser::Error> {
50 toml::to_string_pretty(self)
51 }
52
53 #[cfg(feature = "std")]
55 pub fn from_toml(s: &str) -> Result<Self, toml::de::Error> {
56 toml::from_str(s)
57 }
58
59 pub fn to_json(&self) -> Result<String, serde_json::Error> {
61 serde_json::to_string_pretty(self)
62 }
63
64 pub fn from_json(s: &str) -> Result<Self, serde_json::Error> {
66 serde_json::from_str(s)
67 }
68}