Skip to main content

harmos_packaging/bundle/
manifest.rs

1/* ***
2 *
3 * Harmos
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 *
7 * ***
8 */
9
10/* === Modules === */
11
12/* === Re-Exports === */
13
14/* === Imports === */
15
16// Standard Library Imports
17
18// Third Party Imports
19use serde::{Deserialize, Serialize};
20// Local Imports
21
22/* === Constants === */
23
24/* === Macros === */
25
26/* === Type Aliases === */
27
28/* === Structs === */
29
30#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
31#[serde(deny_unknown_fields)]
32pub struct Identity {
33    pub name: String,
34    pub version: semver::Version,
35    pub description: String,
36
37    #[serde(default)]
38    pub package: PackageMetadata,
39}
40
41#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
42#[serde(deny_unknown_fields)]
43pub struct PackageMetadata {
44    pub authors: Vec<String>,
45    pub license: Option<String>,
46    pub repository: Option<String>,
47    pub homepage: Option<String>,
48    pub documentation: Option<String>,
49    pub keywords: Vec<String>,
50    pub categories: Vec<String>,
51}
52
53#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
54#[serde(deny_unknown_fields)]
55pub struct Manifest {
56    pub schema: u32,
57    pub identity: Identity,
58    pub files: Vec<File>,
59}
60
61#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
62#[serde(deny_unknown_fields)]
63pub struct File {
64    pub path: String,
65    pub size: u64,
66    pub sha256: String,
67
68    #[serde(skip_serializing_if = "Option::is_none", default)]
69    pub executable: Option<Executable>,
70}
71
72#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
73#[serde(deny_unknown_fields)]
74pub struct Executable {
75    pub facility: Facility,
76    pub target: String,
77    pub registrations: Vec<harmos_domain::Registration>,
78}
79
80#[derive(Clone, Copy, Debug)]
81pub struct Limits {
82    pub archive_bytes: usize,
83    pub manifest_bytes: usize,
84    pub file_bytes: usize,
85    pub total_file_bytes: usize,
86    pub files: usize,
87    pub registrations: usize,
88}
89
90/* === Enums === */
91
92#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
93#[serde(rename_all = "lowercase")]
94pub enum Facility {
95    Sidecar,
96    Guest,
97}
98
99/* === Traits === */
100
101/* === Implementations === */
102
103impl Default for Limits {
104    fn default() -> Self {
105        Self {
106            archive_bytes: 272 * 1024 * 1024,
107            manifest_bytes: 16 * 1024 * 1024,
108            file_bytes: 128 * 1024 * 1024,
109            total_file_bytes: 256 * 1024 * 1024,
110            files: 4096,
111            registrations: 1024,
112        }
113    }
114}
115
116/* === Public Functions === */
117
118/* === Private Functions === */
119
120/* === Tests === */