feat: derive macro for loading a cosmic-config
This commit is contained in:
parent
f433b3dc20
commit
76fd9207e5
5 changed files with 98 additions and 2 deletions
|
|
@ -3,10 +3,16 @@ name = "cosmic-config"
|
|||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[features]
|
||||
default = ["macro"]
|
||||
macro = ["cosmic-config-derive"]
|
||||
|
||||
[dependencies]
|
||||
atomicwrites = "0.4.0"
|
||||
calloop = { version = "0.10.5", optional = true }
|
||||
dirs = "4.0.0"
|
||||
notify = "5.1.0"
|
||||
dirs = "5.0.1"
|
||||
notify = "6.0.0"
|
||||
ron = "0.8.0"
|
||||
serde = "1.0.152"
|
||||
cosmic-config-derive = { path = "../cosmic-config-derive/", optional = true }
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@ use std::{
|
|||
sync::Mutex,
|
||||
};
|
||||
|
||||
#[cfg(feature = "macro")]
|
||||
pub use cosmic_config_derive;
|
||||
|
||||
#[cfg(feature = "calloop")]
|
||||
pub mod calloop;
|
||||
|
||||
|
|
@ -251,3 +254,9 @@ impl<'a> ConfigSet for ConfigTransaction<'a> {
|
|||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub trait CosmicConfigEntry where Self: Sized + Default {
|
||||
fn write_entry(&self, config: &Config) -> Result<(), crate::Error>;
|
||||
fn get_entry(config: &Config) -> Result<Self, (Vec<crate::Error>, Self)>;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue