pub struct Config { /* private fields */ }Expand description
A validated configuration.
Built by Config::from_document, never deserialized directly: a source’s name
has to be checked against the pattern the environment mapping depends on, and
default_sources has to name sources that exist, and both are worth a message
that says which key is wrong rather than serde’s own.
Its fields are read through the methods below rather than reached into, because
“validated” is a claim about the whole value: a public sources would let a caller
hold a Config whose default_sources names something it does not contain, and a
public SourceConfig would let one hold a block its own plugin refuses. Neither
state is representable while the only way in is Config::from_document.
Implementations§
Source§impl Config
impl Config
Sourcepub fn from_document(document: Value) -> Result<Self, ConfigError>
pub fn from_document(document: Value) -> Result<Self, ConfigError>
Read one merged document into a validated configuration.
§Errors
Returns ConfigError::Setting naming the offending key for an unknown
field, a value of the wrong shape, a plugin: this build does not have, a
source name that does not match
SOURCE_NAME_PATTERN, a
default_sources entry naming a source nothing configures, or a config:
block the source’s own plugin refuses.
Sourcepub fn page_size(&self) -> NonZeroU32
pub fn page_size(&self) -> NonZeroU32
How many items a page holds.
Sourcepub fn output(&self) -> OutputFormat
pub fn output(&self) -> OutputFormat
How output is rendered.
Sourcepub fn sources(&self) -> &BTreeMap<SourceName, SourceConfig>
pub fn sources(&self) -> &BTreeMap<SourceName, SourceConfig>
Every configured source, in name order.
Sourcepub fn default_sources(&self) -> Option<&[SourceName]>
pub fn default_sources(&self) -> Option<&[SourceName]>
Which sources answer when a command names none, or None for every one.
Sourcepub fn selected_sources(&self) -> Vec<SourceName>
pub fn selected_sources(&self) -> Vec<SourceName>
The sources a command answers from when it names none, in a stable order.