pub struct Config {
pub template: Template,
pub cookie: Option<String>,
pub editor: String,
pub config_dir: PathBuf,
}Expand description
Validated configuration.
Fields§
§template: TemplateThe parsed project path template.
The Advent of Code session cookie, if one is available.
editor: StringThe command launched by aoc code.
config_dir: PathBufThe directory the configuration was loaded from.
Implementations§
Source§impl Config
impl Config
Sourcepub fn load(env: &Env) -> Result<(Self, Vec<Warning>), ConfigError>
pub fn load(env: &Env) -> Result<(Self, Vec<Warning>), ConfigError>
Loads and validates the configuration described by env.
Returns the configuration together with any non-fatal warnings, such as
unrecognised keys - a misspelled cookies: would otherwise silently
disable submission.
With no cookie in the environment or the file itself, the
COOKIE_FILE_NAME file beside config.yaml is read as one.
§Errors
Returns ConfigError if the file is missing, unreadable, not valid
YAML, contains an invalid template_path, or if a cookie file exists
but cannot be read.
Sourcepub fn from_yaml(
contents: &str,
env: &Env,
) -> Result<(Self, Vec<Warning>), ConfigError>
pub fn from_yaml( contents: &str, env: &Env, ) -> Result<(Self, Vec<Warning>), ConfigError>
Parses configuration from a YAML document, resolving paths and the
session cookie against env. Unlike Config::load, this does not
fall back to the cookie file.
§Errors
Returns ConfigError if the document is not valid YAML or the
template_path is not a valid template.