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
File(PathFile)
Dir(PathDir)
Methods
impl PathType
[src]
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")?;
fn from_abs(abs: PathAbs) -> Result<PathType>
[src]
Consume the PathAbs
returning the PathType
.
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();
fn unwrap_dir(self) -> PathDir
[src]
Unwrap the PathType
as a PathDir
.
Examples
use path_abs::PathType; let src = PathType::new("src")?.unwrap_dir();
fn is_dir(&self) -> bool
[src]
Return whether this variant is PathType::Dir
.
fn is_file(&self) -> bool
[src]
Return whether this variant is PathType::File
.
fn mock_file<P: AsRef<Path>>(path: P) -> PathType
[src]
Create a mock file type. For use in tests only.
See the docs for PathAbs::mock
fn mock_dir<P: AsRef<Path>>(path: P) -> PathType
[src]
Create a mock dir type. For use in tests only.
See the docs for PathAbs::mock
Methods from Deref<Target = PathAbs>
fn into_file(self) -> Result<PathFile>
[src]
Resolve the PathAbs
as a PathFile
. Return an error if it is not a file.
fn into_dir(self) -> Result<PathDir>
[src]
Resolve the PathAbs
as a PathDir
. Return an error if it is not a directory.
fn parent_dir(&self) -> Option<PathDir>
[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);
fn as_path(&self) -> &Path
[src]
Return a reference to a basic std::path::Path
Trait Implementations
impl Debug for PathType
[src]
impl Clone for PathType
[src]
fn clone(&self) -> PathType
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Eq for PathType
[src]
impl Hash for PathType
[src]
fn hash<__H: Hasher>(&self, __arg_0: &mut __H)
[src]
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl PartialEq for PathType
[src]
fn eq(&self, __arg_0: &PathType) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &PathType) -> bool
[src]
This method tests for !=
.
impl PartialOrd for PathType
[src]
fn partial_cmp(&self, __arg_0: &PathType) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &PathType) -> bool
[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &PathType) -> bool
[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, __arg_0: &PathType) -> bool
[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &PathType) -> bool
[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]
fn cmp(&self, __arg_0: &PathType) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.22.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.22.0[src]
Compares and returns the minimum of two values. Read more
impl AsRef<PathAbs> for PathType
[src]
impl AsRef<PathArc> for PathType
[src]
impl AsRef<Path> for PathType
[src]
impl AsRef<PathBuf> for PathType
[src]
impl Deref for PathType
[src]
type Target = PathAbs
The resulting type after dereferencing.
fn deref(&self) -> &PathAbs
[src]
Dereferences the value.
impl Borrow<PathAbs> for PathType
[src]
impl Borrow<PathArc> for PathType
[src]
impl Borrow<Path> for PathType
[src]
impl Borrow<PathBuf> for PathType
[src]
impl<'a> Borrow<PathAbs> for &'a PathType
[src]
impl<'a> Borrow<PathArc> for &'a PathType
[src]
impl<'a> Borrow<Path> for &'a PathType
[src]
impl<'a> Borrow<PathBuf> for &'a PathType
[src]
impl Into<PathAbs> for PathType
[src]
fn into(self) -> PathAbs
[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();