packager/manifest/src/package.rs

45 lines
998 B
Rust
Raw Normal View History

2023-07-13 00:11:44 +02:00
use std::str::FromStr;
use serde::{Deserialize, Serialize};
2023-07-13 00:11:44 +02:00
#[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<String>,
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<Package, toml::de::Error> {
toml::from_str(s)
}
}