pub struct InputPath { /* private fields */ }
Expand description
A builder for Input that validates the path but defers creating it until you call the open 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§
source§impl InputPath
impl InputPath
sourcepub fn new<S: TryInto<ClioPath>>(path: S) -> Result<Self>
pub fn new<S: TryInto<ClioPath>>(path: S) -> Result<Self>
Constructs 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
sourcepub fn is_local(&self) -> bool
pub fn is_local(&self) -> bool
Returns true if this InputPath
is on the local file system,
as opposed to point to stdin or a URL
Trait Implementations§
source§impl PartialEq for InputPath
impl PartialEq for InputPath
source§impl ValueParserFactory for InputPath
Available on crate feature clap-parse
only.
impl ValueParserFactory for InputPath
Available on crate feature
clap-parse
only.§type Parser = OsStrParser<InputPath>
type Parser = OsStrParser<InputPath>
Generated parser, usually [
ValueParser
]. Read moresource§fn value_parser() -> Self::Parser
fn value_parser() -> Self::Parser
Create the specified [
Self::Parser
]impl Eq for InputPath
impl StructuralEq for InputPath
impl StructuralPartialEq for InputPath
Auto Trait Implementations§
impl RefUnwindSafe for InputPath
impl Send for InputPath
impl Sync for InputPath
impl Unpin for InputPath
impl UnwindSafe for InputPath
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