pub struct InputPath { /* private fields */ }
Expand description

A builder for Input that validates the path but defers creating it until you call the create method.

It is designed to be used with the clap crate when taking a file name as an argument to CLI app

use clap::Parser;
use clio::InputPath;

#[derive(Parser)]
struct Opt {
    /// path to file, use '-' for stdin
    #[clap(value_parser)]
    input_file: InputPath,
}

Implementations

Contructs a new InputPath representing the path and checking that the file exists and is readable

note: even if this passes open may still fail if e.g. the file was delete in between

Contructs a new InputPath to stdout (“-”)

Create an Input by opening the file or for ‘-’ returning stdin

The original path used to create this InputPath

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

formats as the path it was created from

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.