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: symlinks are not supported because they are impossible for canonicalized paths.
Variants
File(PathFile)
Dir(PathDir)
Methods
impl PathType
[src]
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")?;
fn from_abs(abs: PathAbs) -> Result<PathType, Error>
[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>(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
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
Trait Implementations
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,
impl Ord for PathType
[src]
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 Clone for PathType
[src]
impl Eq for PathType
[src]
impl PartialEq<PathType> for PathType
[src]
impl Debug for PathType
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result<(), Error>
[src]
Formats the value using the given formatter.
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>,