init: initial commit of packager
This commit is contained in:
commit
7964bb84fd
25 changed files with 478 additions and 0 deletions
10
manifest/Cargo.toml
Normal file
10
manifest/Cargo.toml
Normal file
|
@ -0,0 +1,10 @@
|
|||
[package]
|
||||
name = "manifest"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
toml = "0.7.6"
|
||||
serde = { version = "1.0.171", features = ["derive"] }
|
7
manifest/src/bin.rs
Normal file
7
manifest/src/bin.rs
Normal file
|
@ -0,0 +1,7 @@
|
|||
use serde::{Serialize, Deserialize};
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct Bin {
|
||||
pub root: String,
|
||||
|
||||
}
|
10
manifest/src/build.rs
Normal file
10
manifest/src/build.rs
Normal file
|
@ -0,0 +1,10 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct Build {
|
||||
build_script: String,
|
||||
install_script: String,
|
||||
dependencies: HashMap<String, String>
|
||||
}
|
16
manifest/src/fs.rs
Normal file
16
manifest/src/fs.rs
Normal file
|
@ -0,0 +1,16 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct FS {
|
||||
pub config: Option<String>,
|
||||
pub data: Option<String>,
|
||||
}
|
||||
|
||||
impl Default for FS {
|
||||
fn default() -> Self {
|
||||
FS {
|
||||
config: None,
|
||||
data: None,
|
||||
}
|
||||
}
|
||||
}
|
32
manifest/src/lib.rs
Normal file
32
manifest/src/lib.rs
Normal file
|
@ -0,0 +1,32 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
|
||||
pub mod package;
|
||||
pub mod fs;
|
||||
pub mod bin;
|
||||
pub mod build;
|
||||
pub mod pkgr;
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[serde(default)]
|
||||
pub struct Manifest<P = Option<pkgr::PKGR>> {
|
||||
pub package: package::Package,
|
||||
pub dependencies: HashMap<String, String>,
|
||||
pub fs: fs::FS,
|
||||
pub bin: Option<bin::Bin>,
|
||||
pub build: Option<build::Build>,
|
||||
pub pkgr: P
|
||||
}
|
||||
|
||||
impl Default for Manifest {
|
||||
fn default() -> Self {
|
||||
Manifest {
|
||||
package: package::Package::default(),
|
||||
dependencies: HashMap::default(),
|
||||
fs: fs::FS::default(),
|
||||
bin: None,
|
||||
build: None,
|
||||
pkgr: None
|
||||
}
|
||||
}
|
||||
}
|
45
manifest/src/package.rs
Normal file
45
manifest/src/package.rs
Normal file
|
@ -0,0 +1,45 @@
|
|||
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)
|
||||
}
|
||||
}
|
4
manifest/src/pkgr.rs
Normal file
4
manifest/src/pkgr.rs
Normal file
|
@ -0,0 +1,4 @@
|
|||
use serde::{Serialize, Deserialize};
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct PKGR {}
|
Loading…
Add table
Add a link
Reference in a new issue