packager/manifest/src/package.rs

46 lines
1,002 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")]
2023-07-16 19:01:20 +02:00
Meta,
2023-07-13 00:11:44 +02:00
}
#[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>,
2023-07-16 19:01:20 +02:00
pub arch: String,
2023-07-13 00:11:44 +02:00
}
impl Default for Package {
fn default() -> Self {
Package {
name: String::default(),
description: String::default(),
package_type: PackageType::Application,
version: 0,
tags: Vec::default(),
2023-07-16 19:01:20 +02:00
arch: std::env::consts::ARCH.to_string(),
2023-07-13 00:11:44 +02:00
}
}
}
impl FromStr for Package {
type Err = toml::de::Error;
fn from_str(s: &str) -> Result<Package, toml::de::Error> {
toml::from_str(s)
}
2023-07-16 19:01:20 +02:00
}