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: symlinks are not supported because they are impossible for canonicalized paths.

Variants

Methods

impl PathType
[src]

[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")?;

[src]

Consume the PathAbs returning the PathType.

[src]

Unwrap the PathType as a PathFile.

Examples

use path_abs::PathType;

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

[src]

Unwrap the PathType as a PathDir.

Examples

use path_abs::PathType;

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

[src]

Return whether this variant is PathType::Dir.

[src]

Return whether this variant is PathType::File.

[src]

Create a mock file type. For use in tests only.

See the docs for PathAbs::mock

[src]

Create a mock dir type. For use in tests only.

See the docs for PathAbs::mock

Methods from Deref<Target = PathAbs>

[src]

Resolve the PathAbs as a PathFile. Return an error if it is not a file.

[src]

Resolve the PathAbs as a PathDir. Return an error if it is not a directory.

[src]

Get the parent directory of this path as a PathDir.

This does not make aditional syscalls, as the parent by definition must be a directory and exist.

Examples

use path_abs::{PathDir, PathFile};

let lib = PathFile::new("src/lib.rs")?;
let src = lib.parent_dir().unwrap();
assert_eq!(PathDir::new("src")?, src);

[src]

Return a reference to a basic std::path::Path

Trait Implementations

impl Debug for PathType
[src]

[src]

Formats the value using the given formatter.

impl Clone for PathType
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Eq for PathType
[src]

impl Hash for PathType
[src]

[src]

Feeds this value into the given [Hasher]. Read more

1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl PartialEq for PathType
[src]

[src]

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

[src]

This method tests for !=.

impl PartialOrd for PathType
[src]

[src]

This method returns an ordering between self and other values if one exists. Read more

[src]

This method tests less than (for self and other) and is used by the < operator. Read more

[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Ord for PathType
[src]

[src]

This method returns an Ordering between self and other. Read more

1.22.0
[src]

Compares and returns the maximum of two values. Read more

1.22.0
[src]

Compares and returns the minimum of two values. Read more

impl AsRef<PathAbs> for PathType
[src]

[src]

Performs the conversion.

impl AsRef<PathArc> for PathType
[src]

[src]

Performs the conversion.

impl AsRef<Path> for PathType
[src]

[src]

Performs the conversion.

impl AsRef<PathBuf> for PathType
[src]

[src]

Performs the conversion.

impl Deref for PathType
[src]

The resulting type after dereferencing.

[src]

Dereferences the value.

impl Borrow<PathAbs> for PathType
[src]

[src]

Immutably borrows from an owned value. Read more

impl Borrow<PathArc> for PathType
[src]

[src]

Immutably borrows from an owned value. Read more

impl Borrow<Path> for PathType
[src]

[src]

Immutably borrows from an owned value. Read more

impl Borrow<PathBuf> for PathType
[src]

[src]

Immutably borrows from an owned value. Read more

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

[src]

Immutably borrows from an owned value. Read more

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

[src]

Immutably borrows from an owned value. Read more

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

[src]

Immutably borrows from an owned value. Read more

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

[src]

Immutably borrows from an owned value. Read more

impl Into<PathAbs> for PathType
[src]

[src]

Downgrades the PathType into a PathAbs

Examples

use std::path::PathBuf;
use path_abs::{PathType, PathAbs};

let ty = PathType::new("src/lib.rs")?;
let abs: PathAbs = ty.into();

impl Into<PathArc> for PathType
[src]

[src]

Downgrades the PathType into a PathArc

impl Into<PathBuf> for PathType
[src]

[src]

Downgrades the PathType into a PathBuf. Avoids a clone if this is the only reference.

Examples

use path_abs::PathType;
use std::path::PathBuf;

let ty = PathType::new("src/lib.rs")?;
let buf: PathBuf = ty.into();