Enum Input

Source
pub enum Input {
    Path(PathBuf),
    Stdin,
}
Expand description

An input source for reading.

Variants§

§

Path(PathBuf)

A path from which to read a file.

§

Stdin

Stdin.

Implementations§

Source§

impl Input

Source

pub const ENV_KEY_DISABLE_CHECK: &'static str = "SFS_ALLOW_STDIN"

By default, reading an Input checks that either a path is provided, or that input is available via stdin, instead of hanging.

In some contexts, e.g. testing, this can cause issues, and so it may be disabled by setting this environment variable, or by using Input::new_unchecked.

Source

pub fn new(input: Option<PathBuf>) -> Result<Self>

Creates a new input source.

Source

pub fn new_unchecked(input: Option<PathBuf>) -> Self

Creates a new input source without checking that any data is available.

Source

pub fn open(&self) -> Result<Reader>

Open the input for reading.

Source

pub fn as_path(&self) -> Option<&Path>

Returns the provided path if provided, otherwise None.

Trait Implementations§

Source§

impl Debug for Input

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Input> for Option<PathBuf>

Source§

fn from(input: Input) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Input

§

impl RefUnwindSafe for Input

§

impl Send for Input

§

impl Sync for Input

§

impl Unpin for Input

§

impl UnwindSafe for Input

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.