Skip to main content

PathType

Struct PathType 

Source
pub struct PathType {
    pub exists: bool,
    pub file_okay: bool,
    pub dir_okay: bool,
    pub readable: bool,
    pub writable: bool,
    pub executable: bool,
    pub resolve_path: bool,
    pub allow_dash: bool,
}
Expand description

A parameter type for file system paths with optional validation.

Unlike the File type, this returns the path as a PathBuf rather than opening the file.

Fields§

§exists: bool

Whether the path must exist.

§file_okay: bool

Whether files are allowed.

§dir_okay: bool

Whether directories are allowed.

§readable: bool

Whether the path must be readable.

§writable: bool

Whether the path must be writable.

§executable: bool

Whether the path must be executable.

§resolve_path: bool

Whether to resolve the path to an absolute path.

§allow_dash: bool

Whether to allow “-” to indicate stdin/stdout.

Implementations§

Source§

impl PathType

Source

pub const fn new() -> Self

Create a new path type with default settings.

Source

pub const fn exists(self, exists: bool) -> Self

Require the path to exist.

Source

pub const fn file_okay(self, file_okay: bool) -> Self

Allow only files (not directories).

Source

pub const fn dir_okay(self, dir_okay: bool) -> Self

Allow only directories (not files).

Source

pub const fn readable(self, readable: bool) -> Self

Require the path to be readable.

Source

pub const fn writable(self, writable: bool) -> Self

Require the path to be writable.

Source

pub const fn executable(self, executable: bool) -> Self

Require the path to be executable.

Source

pub const fn resolve_path(self, resolve_path: bool) -> Self

Resolve the path to an absolute path.

Source

pub const fn allow_dash(self, allow_dash: bool) -> Self

Allow “-” to indicate stdin/stdout.

Trait Implementations§

Source§

impl Clone for PathType

Source§

fn clone(&self) -> PathType

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PathType

Source§

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

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

impl Default for PathType

Source§

fn default() -> Self

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

impl TypeConverter for PathType

Source§

type Value = PathBuf

The Rust type that this parameter type converts to.
Source§

fn name(&self) -> &str

Returns the descriptive name of this type (used in error messages).
Source§

fn convert(&self, value: &str) -> Result<Self::Value, String>

Convert a string value to the target type. Read more
Source§

fn split_envvar_value(&self, value: &str) -> Vec<String>

Split an environment variable value into multiple values. Read more
Source§

fn shell_complete(&self, incomplete: &str) -> Vec<CompletionItem>

Returns shell completion items for the given incomplete value. Read more
Source§

fn get_metavar(&self) -> Option<String>

Returns the metavar for this type (used in help text). Read more
Source§

fn get_missing_message(&self) -> Option<String>

Returns an optional message when a required value is missing.
Source§

fn is_composite(&self) -> bool

Whether this type is a composite type (like Tuple).
Source§

fn arity(&self) -> usize

The arity (number of values consumed) for composite types.

Auto Trait Implementations§

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> AnyTypeConverter for T
where T: TypeConverter + Send + Sync, <T as TypeConverter>::Value: Send + Sync + 'static,

Source§

fn name(&self) -> &str

Returns the descriptive name of this type.
Source§

fn convert_any(&self, value: &str) -> Result<Box<dyn Any + Sync + Send>, String>

Convert a string value to the target type, returning as Box.
Source§

fn convert_multi( &self, values: &[String], ) -> Result<Box<dyn Any + Sync + Send>, String>

Convert multiple string values to the target type, returning as Box. Read more
Source§

fn get_metavar(&self) -> Option<String>

Returns the metavar for this type.
Source§

fn split_envvar_value(&self, value: &str) -> Vec<String>

Split an environment variable value into multiple values.
Source§

fn shell_complete(&self, incomplete: &str) -> Vec<CompletionItem>

Returns shell completion items for the given incomplete value.
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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.