write shit
This commit is contained in:
30
wfassoc_exec/src/manifest.rs
Normal file
30
wfassoc_exec/src/manifest.rs
Normal file
@ -0,0 +1,30 @@
|
||||
use serde::Deserialize;
|
||||
use std::collections::HashMap;
|
||||
use thiserror::Error as TeError;
|
||||
use toml;
|
||||
|
||||
#[derive(Debug, TeError)]
|
||||
#[error("{0}")]
|
||||
pub enum Error {
|
||||
Io(#[from] std::io::Error),
|
||||
Toml(#[from] toml::de::Error),
|
||||
}
|
||||
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct Manifest {
|
||||
pub(crate) identifier: String,
|
||||
pub(crate) path: String,
|
||||
pub(crate) clsid: String,
|
||||
pub(crate) manners: HashMap<String, String>,
|
||||
pub(crate) exts: HashMap<String, String>,
|
||||
}
|
||||
|
||||
impl Manifest {
|
||||
pub fn from_file(path: &str) -> Result<Manifest> {
|
||||
let contents = std::fs::read_to_string(path)?;
|
||||
let config: Manifest = toml::from_str(&contents)?;
|
||||
Ok(config)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user