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.
§Errors
Returns ConfigError if the file is missing, unreadable, not valid
YAML, or contains an invalid template_path.
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.
§Errors
Returns ConfigError if the document is not valid YAML or the
template_path is not a valid template.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnsafeUnpin for Config
impl UnwindSafe for Config
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more