45 lines
1,016 B
Rust
45 lines
1,016 B
Rust
use std::str::FromStr;
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub enum PackageType {
|
|
#[serde(rename = "application")]
|
|
Application,
|
|
#[serde(rename = "library")]
|
|
Library,
|
|
#[serde(rename = "meta")]
|
|
Meta,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[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)
|
|
}
|
|
}
|