added load_from_file to fomod config
This commit is contained in:
11
src/fomod.rs
11
src/fomod.rs
@@ -2,6 +2,8 @@
|
|||||||
// https://github.com/luctius/fomod/
|
// https://github.com/luctius/fomod/
|
||||||
// Original license: MIT / Apache-2.0
|
// Original license: MIT / Apache-2.0
|
||||||
|
|
||||||
|
use std::{error::Error, fs, path::Path};
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, PartialEq)]
|
#[derive(Debug, Deserialize, PartialEq)]
|
||||||
@@ -41,6 +43,15 @@ pub struct Config {
|
|||||||
pub conditional_file_installs: Option<ConditionalFileInstallList>,
|
pub conditional_file_installs: Option<ConditionalFileInstallList>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Config {
|
||||||
|
pub fn load_from_file(path: impl AsRef<Path>) -> Result<Self, Box<dyn Error>> {
|
||||||
|
let data = fs::read_to_string(path)?;
|
||||||
|
let config = quick_xml::de::from_str(&data)?;
|
||||||
|
|
||||||
|
Ok(config)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq, PartialOrd, Ord, Hash, Default,
|
Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq, PartialOrd, Ord, Hash, Default,
|
||||||
)]
|
)]
|
||||||
|
|||||||
Reference in New Issue
Block a user