flatpak_rs/
manifest_type.rs1use serde::{Deserialize, Serialize};
2
3pub const APPLICATION: &str = "application";
4pub const MODULE: &str = "module";
5pub const SOURCE: &str = "source";
6
7#[derive(Clone)]
9#[derive(Deserialize)]
10#[derive(Serialize)]
11#[derive(Debug)]
12pub enum FlatpakManifestType {
13 Application,
14 Module,
15 Source,
16}
17impl FlatpakManifestType {
18 pub fn to_string(&self) -> String {
19 match &self {
20 FlatpakManifestType::Application => APPLICATION.to_string(),
21 FlatpakManifestType::Module => MODULE.to_string(),
22 FlatpakManifestType::Source => SOURCE.to_string(),
23 }
24 }
25
26 pub fn from_string(manifest_type: &str) -> Result<FlatpakManifestType, String> {
27 if manifest_type == APPLICATION {
28 return Ok(FlatpakManifestType::Application);
29 }
30 if manifest_type == MODULE {
31 return Ok(FlatpakManifestType::Module);
32 }
33 if manifest_type == SOURCE {
34 return Ok(FlatpakManifestType::Source);
35 }
36 Err(format!("Invalid manifest type {}.", manifest_type))
37 }
38}