Skip to main content

ConsoleSpec

Struct ConsoleSpec 

Source
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 str

The name of the desired console driver.

Implementations§

Source§

impl<'a> ConsoleSpec<'a>

Source

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.

Source

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.

Source

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.

Source

pub fn take_keyed_flag<V>(&mut self, key: &str) -> Result<Option<V>, ParseError>
where V: FromStr, V::Err: Display,

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.

Source

pub fn finish(self) -> Result<(), ParseError>

Validates that all provided flags have been queried by the driver.

Auto Trait Implementations§

§

impl<'a> Freeze for ConsoleSpec<'a>

§

impl<'a> RefUnwindSafe for ConsoleSpec<'a>

§

impl<'a> Send for ConsoleSpec<'a>

§

impl<'a> Sync for ConsoleSpec<'a>

§

impl<'a> Unpin for ConsoleSpec<'a>

§

impl<'a> UnsafeUnpin for ConsoleSpec<'a>

§

impl<'a> UnwindSafe for ConsoleSpec<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V