45 lines
998 B
Rust
45 lines
998 B
Rust
|
use std::str::FromStr;
|
||
|
|
||
|
use serde::{Serialize, Deserialize};
|
||
|
|
||
|
#[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)
|
||
|
}
|
||
|
}
|