use std::str::FromStr; use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug)] pub enum PackageType { #[serde(rename = "application")] Application, #[serde(rename = "library")] Library, #[serde(rename = "meta")] Meta } #[derive(Serialize, Deserialize, Debug)] #[serde(default)] pub struct Package { pub name: String, pub description: String, pub package_type: PackageType, pub version: u64, pub tags: Vec, pub arch: String } impl Default for Package { fn default() -> Self { Package { name: String::default(), description: String::default(), package_type: PackageType::Application, version: 0, tags: Vec::default(), arch: std::env::consts::ARCH.to_string() } } } impl FromStr for Package { type Err = toml::de::Error; fn from_str(s: &str) -> Result { toml::from_str(s) } }