pub trait SingleKey: 'static {
type Group: Group;
}Expand description
A key of a single group.
The trait names the group of the key, so
ConfigView::get and RepoConfig::get take the
key as their one type argument. config_group! implements it for each key
of a single group. A key of a named group does not implement it, so a read
of such a key on a ConfigView or a RepoConfig
does not compile.
§Examples
use ostrya_core::KeyFile;
use ostrya_core::config::{ConfigError, ConfigView};
ostrya_core::config_group! {
pub group tool = "ex-tool" {
Jobs: u32 = "jobs", default 4;
}
}
let kf = KeyFile::parse("[core]\nrepo_version=1\nmode=bare\n")?;
assert_eq!(ConfigView::new(&kf).get::<tool::Jobs>()?, 4);A read of a key of a named group does not compile:
ⓘ
use ostrya_core::KeyFile;
use ostrya_core::config::{ConfigError, ConfigView};
ostrya_core::config_group! {
pub group tool = named "ex-tool" {
Jobs: u32 = "jobs", default 4;
}
}
let kf = KeyFile::parse("[core]\nrepo_version=1\nmode=bare\n")?;
let _ = ConfigView::new(&kf).get::<tool::Jobs>()?;Required Associated Types§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".