pub struct Config {
pub asbuilt: Option<String>,
pub output: OutputConfig,
pub docs: DocsConfig,
pub theme: BTreeMap<String, ThemeColor>,
pub externals: Vec<External>,
pub sections: BTreeMap<String, Value>,
pub path: Option<PathBuf>,
}Expand description
The parsed asbuilt.toml.
Other top-level entries stay in sections, where a front-end’s table
([rust], say) waits to be deserialized with that front-end’s schema;
Config::check_tables rejects any that names no front-end. Unknown
keys inside [output] or an [[externals]] entry are rejected
when parsing.
use asbuilt_core::Config;
let config: Config = r#"
[output]
path = "arch/model.c4"
[rust]
include_tests = false
"#
.parse()
.unwrap();
assert_eq!(config.output.path, "arch/model.c4");
assert!(config.sections.contains_key("rust"));Fields§
§asbuilt: Option<String>The asbuilt release this config and its model are written for,
as cargo install --version takes it. Config::load_for checks
it against the running release before reading anything else;
None runs under any release.
output: OutputConfig§docs: DocsConfig§theme: BTreeMap<String, ThemeColor>[theme]: a color per element kind (container, component,
bin, tests, examples, or an external kind), emitted as
LikeC4 element styles so the
diagrams come out in the consumer’s palette.
externals: Vec<External>§sections: BTreeMap<String, Value>§path: Option<PathBuf>Where this config was read from, for error messages. None for a
config parsed from a string or defaulted.
Implementations§
Source§impl Config
impl Config
Sourcepub fn light_theme(&self) -> BTreeMap<String, String>
pub fn light_theme(&self) -> BTreeMap<String, String>
The light color per themed kind, the emitter’s input.
Source§impl Config
impl Config
Sourcepub fn load(root: &Path) -> Result<Self>
pub fn load(root: &Path) -> Result<Self>
The config at root/asbuilt.toml, or the defaults when there is
no such file.
Sourcepub fn load_file(path: &Path) -> Result<Self>
pub fn load_file(path: &Path) -> Result<Self>
A config from an explicit path (--config); a missing file is an
error here, unlike Config::load.
Sourcepub fn load_for(
root: &Path,
config_path: Option<&Path>,
running: &str,
) -> Result<Self>
pub fn load_for( root: &Path, config_path: Option<&Path>, running: &str, ) -> Result<Self>
The config a binary at release running reads: config_path
when given, else root/asbuilt.toml, else the defaults. The pin
is checked against running before the rest of the file is
deserialized, so a config written for another release fails on
the version, not on a table or key this release does not know.
Sourcepub fn file_path(&self) -> PathBuf
pub fn file_path(&self) -> PathBuf
The file this config came from, for error messages: asbuilt.toml
when it was parsed from a string or defaulted.
Sourcepub fn check_tables(&self, frontends: &[&str]) -> Result<()>
pub fn check_tables(&self, frontends: &[&str]) -> Result<()>
Every top-level entry is asbuilt’s own or the table of one of
frontends (by Frontend::name); the
first that is neither is an error naming it as written.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl FromStr for Config
Parsing alone: the pin’s place and shape are checked by the loaders,
which know the file to name.
impl FromStr for Config
Parsing alone: the pin’s place and shape are checked by the loaders, which know the file to name.