pub struct ConsoleSpec<'a> {
pub driver: &'a str,
/* private fields */
}Expand description
Parser for a console specification.
A console specification is a string of the form driver[:flags]. The optional flags are a
sequence of comma-separated flags where each flag can be a a boolean flag represented as a plain
string or keyed flag represented as a key=value string.
The interface of this parser is designed to be instantiated from main based on a user-supplied
flag and then passed on to the specific console drivers for additional parsing. main then
needs to call finish to ensure that all provided flags have been parsed.
Fields§
§driver: &'a strThe name of the desired console driver.
Implementations§
Source§impl<'a> ConsoleSpec<'a>
impl<'a> ConsoleSpec<'a>
Sourcepub fn init(s: &'a str) -> Self
pub fn init(s: &'a str) -> Self
Initializes the console specification parser from s.
s must not be empty. The caller must supply, at least, a default console driver name
if the user did not specify any console flag.
Sourcepub fn take_flag(&mut self, flag: &str) -> bool
pub fn take_flag(&mut self, flag: &str) -> bool
Queries whether the boolean flag is in the specification or not.
The flag is marked as “checked” so that finish won’t raise it as residual.
Sourcepub fn take_keyed_flag_str(&mut self, key: &str) -> Option<&str>
pub fn take_keyed_flag_str(&mut self, key: &str) -> Option<&str>
Queries the value of the keyed flag from the specification, which may or may not be
present. The value is returned as a raw string.
Sourcepub fn take_keyed_flag<V>(&mut self, key: &str) -> Result<Option<V>, ParseError>
pub fn take_keyed_flag<V>(&mut self, key: &str) -> Result<Option<V>, ParseError>
Queries the value of the keyed flag from the specification, which may or may not be
present. The value is parsed according to the type V.
The flag is marked as “checked” so that finish won’t raise it as residual.
Sourcepub fn finish(self) -> Result<(), ParseError>
pub fn finish(self) -> Result<(), ParseError>
Validates that all provided flags have been queried by the driver.