conduit_cli/core/io/modpack/
metadata.rs1use serde::{Deserialize, Serialize};
2use crate::core::error::{CoreError, CoreResult};
3use crate::core::io::project::manifest::InstanceType;
4
5#[derive(Serialize, Deserialize, Debug, Clone)]
6pub struct ConduitPackMetadata {
7 pub conduit: ConduitInfo,
8 pub pack: PackInfo,
9 pub content: ContentFlags,
10}
11
12#[derive(Serialize, Deserialize, Debug, Clone)]
13pub struct ConduitInfo {
14 pub version: String,
15 pub format_version: i32,
16}
17
18#[derive(Serialize, Deserialize, Debug, Clone)]
19pub struct PackInfo {
20 pub title: String,
21 pub creator: Option<String>,
22 pub description: Option<String>,
23 pub homepage: Option<String>,
24 pub repository: Option<String>,
25 #[serde(rename = "type")]
26 pub pack_type: InstanceType,
27}
28
29#[derive(Serialize, Deserialize, Debug, Clone)]
30pub struct ContentFlags {
31 pub has_configs: bool,
32 pub has_mods_overrides: bool,
33}
34
35impl ConduitPackMetadata {
36 pub fn to_toml(&self) -> CoreResult<String> {
37 toml::to_string(self).map_err(|e| {
38 CoreError::RuntimeError(format!("Failed to serialize pack metadata: {e}"))
39 })
40 }
41
42 pub fn from_toml(content: &str) -> CoreResult<Self> {
43 toml::from_str(content).map_err(|e| {
44 CoreError::RuntimeError(format!("Failed to parse pack metadata: {e}"))
45 })
46 }
47}