Enum ergo_fs::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)
Methods
impl PathType
[src]
pub fn new<P>(path: P) -> Result<PathType, Error> where
P: AsRef<Path>,
[src]
P: AsRef<Path>,
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 from_abs(abs: PathAbs) -> Result<PathType, Error>
[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
.
pub fn mock_file<P>(path: P) -> PathType where
P: AsRef<Path>,
[src]
P: AsRef<Path>,
Create a mock file type. For use in tests only.
See the docs for PathAbs::mock
pub fn mock_dir<P>(path: P) -> PathType where
P: AsRef<Path>,
[src]
P: AsRef<Path>,
Create a mock dir type. For use in tests only.
See the docs for PathAbs::mock
Methods from Deref<Target = PathAbs>
pub 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);
pub fn as_path(&self) -> &Path
[src]
Return a reference to a basic std::path::Path
Trait Implementations
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.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
impl AsRef<PathBuf> for PathType
[src]
impl AsRef<PathArc> for PathType
[src]
impl AsRef<Path> for PathType
[src]
impl AsRef<PathAbs> for PathType
[src]
impl PartialOrd<PathType> 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 Deref for PathType
[src]
type Target = PathAbs
The resulting type after dereferencing.
fn deref(&self) -> &PathAbs
[src]
Dereferences the value.
impl Into<PathArc> for 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();
impl Into<PathBuf> for PathType
[src]
fn into(self) -> PathBuf
[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();
impl<'de> Deserialize<'de> for PathType
[src]
fn deserialize<__D>(
__deserializer: __D
) -> Result<PathType, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
[src]
__deserializer: __D
) -> Result<PathType, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Hash for PathType
[src]
fn hash<__H>(&self, __arg_0: &mut __H) where
__H: Hasher,
[src]
__H: Hasher,
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 Eq for PathType
[src]
impl PartialEq<PathType> 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<'a> Borrow<PathArc> for &'a PathType
[src]
impl Borrow<PathAbs> for PathType
[src]
impl Borrow<PathArc> for PathType
[src]
impl Borrow<Path> for PathType
[src]
impl<'a> Borrow<PathAbs> for &'a PathType
[src]
impl<'a> Borrow<PathBuf> for &'a PathType
[src]
impl Borrow<PathBuf> for PathType
[src]
impl<'a> Borrow<Path> for &'a PathType
[src]
impl Serialize for PathType
[src]
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
[src]
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
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 Debug for PathType
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result<(), Error>
[src]
Formats the value using the given formatter. Read more