Struct clio::OutputPath
source · [−]pub struct OutputPath { /* private fields */ }
Expand description
A builder for Output 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::OutputPath;
#[derive(Parser)]
struct Opt {
/// path to file, use '-' for stdout
#[clap(value_parser)]
output_file: OutputPath,
}
Implementations
sourceimpl OutputPath
impl OutputPath
sourcepub fn new<S: AsRef<OsStr>>(path: S) -> Result<Self>
pub fn new<S: AsRef<OsStr>>(path: S) -> Result<Self>
Construct a new OutputPath
from an string
It checks if an output file could plausibly be created at that path
sourcepub fn std() -> Self
pub fn std() -> Self
Contructs a new OutputPath
of "-"
for stdout
sourcepub fn create_with_len(self, size: u64) -> Result<Output>
pub fn create_with_len(self, size: u64) -> Result<Output>
Creater the file with a predetermined length, either using File::set_len
or as the content-length
header of the http put
sourcepub fn path(&self) -> &OsStr
pub fn path(&self) -> &OsStr
The original path represented by this OutputPath
Trait Implementations
sourceimpl Debug for OutputPath
impl Debug for OutputPath
sourceimpl Default for OutputPath
impl Default for OutputPath
sourceimpl Display for OutputPath
impl Display for OutputPath
formats as the path it was created from
sourceimpl PartialEq<OutputPath> for OutputPath
impl PartialEq<OutputPath> for OutputPath
sourcefn eq(&self, other: &OutputPath) -> bool
fn eq(&self, other: &OutputPath) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &OutputPath) -> bool
fn ne(&self, other: &OutputPath) -> bool
This method tests for !=
.
sourceimpl TryFrom<&'_ OsStr> for OutputPath
impl TryFrom<&'_ OsStr> for OutputPath
impl Eq for OutputPath
impl StructuralEq for OutputPath
impl StructuralPartialEq for OutputPath
Auto Trait Implementations
impl RefUnwindSafe for OutputPath
impl Send for OutputPath
impl Sync for OutputPath
impl Unpin for OutputPath
impl UnwindSafe for OutputPath
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more