1
0
Files
wfassoc/wfassoc_exec/src/manifest.rs
2025-10-17 14:19:26 +08:00

30 lines
736 B
Rust

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)
}
}