Enum path_abs::PathType[][src]

pub enum PathType {
    File(PathFile),
    Dir(PathDir),
}

An an enum containing either a file or a directory.

This is used primarily for:

  • The items returned from PathDir::list
  • Serializing paths of different types.

Note that for symlinks, this returns the underlying file type.

Variants

File(PathFile)
Dir(PathDir)

Implementations

impl PathType[src]

pub fn new<P: AsRef<Path>>(path: P) -> Result<PathType>[src]

Resolves and returns the PathType of the given path.

If the path exists but is not a file or a directory (i.e. is a symlink), then io::ErrorKind::InvalidInput is returned.

Examples

use path_abs::PathType;

let src = PathType::new("src")?;

pub fn try_from<P: Into<PathAbs>>(path: P) -> Result<PathType>[src]

Consume the PathAbs returning the PathType.

pub fn unwrap_file(self) -> PathFile[src]

Unwrap the PathType as a PathFile.

Examples

use path_abs::PathType;

let lib = PathType::new("src/lib.rs")?.unwrap_file();

pub fn unwrap_dir(self) -> PathDir[src]

Unwrap the PathType as a PathDir.

Examples

use path_abs::PathType;

let src = PathType::new("src")?.unwrap_dir();

pub fn is_dir(&self) -> bool[src]

Return whether this variant is PathType::Dir.

pub fn is_file(&self) -> bool[src]

Return whether this variant is PathType::File.

Trait Implementations

impl AsRef<OsStr> for PathType[src]

impl AsRef<Path> for PathType[src]

impl AsRef<PathAbs> for PathType[src]

impl AsRef<PathBuf> for PathType[src]

impl Borrow<Path> for PathType[src]

impl<'a> Borrow<Path> for &'a PathType[src]

impl Borrow<PathAbs> for PathType[src]

impl<'a> Borrow<PathAbs> for &'a PathType[src]

impl Borrow<PathBuf> for PathType[src]

impl<'a> Borrow<PathBuf> for &'a PathType[src]

impl Clone for PathType[src]

impl Debug for PathType[src]

impl<'de> Deserialize<'de> for PathType[src]

impl Eq for PathType[src]

impl From<PathType> for PathAbs[src]

impl Hash for PathType[src]

impl Ord for PathType[src]

impl PartialEq<PathType> for PathType[src]

impl PartialOrd<PathType> for PathType[src]

impl PathOps for PathType[src]

type Output = PathAbs

impl Serialize for PathType[src]

impl StructuralEq for PathType[src]

impl StructuralPartialEq for PathType[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> PathInfo for T where
    T: Clone + Borrow<PathBuf> + Into<Arc<PathBuf>>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToStfu8 for T where
    T: Borrow<PathBuf>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.