pub enum PathType {
File(PathFile),
Dir(PathDir),
}Expand description
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§
Implementations§
Source§impl PathType
impl PathType
Sourcepub fn new<P: AsRef<Path>>(path: P) -> Result<PathType>
pub fn new<P: AsRef<Path>>(path: P) -> Result<PathType>
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::InvalidInputis returned.
§Examples
use path_abs::PathType;
let src = PathType::new("src")?;Sourcepub fn try_from<P: Into<PathAbs>>(path: P) -> Result<PathType>
pub fn try_from<P: Into<PathAbs>>(path: P) -> Result<PathType>
Consume the PathAbs returning the PathType.
Sourcepub fn unwrap_file(self) -> PathFile
pub fn unwrap_file(self) -> PathFile
Unwrap the PathType as a PathFile.
§Examples
use path_abs::PathType;
let lib = PathType::new("src/lib.rs")?.unwrap_file();Sourcepub fn unwrap_dir(self) -> PathDir
pub fn unwrap_dir(self) -> PathDir
Unwrap the PathType as a PathDir.
§Examples
use path_abs::PathType;
let src = PathType::new("src")?.unwrap_dir();Trait Implementations§
Source§impl<'de> Deserialize<'de> for PathType
impl<'de> Deserialize<'de> for PathType
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Ord for PathType
impl Ord for PathType
Source§impl PartialOrd for PathType
impl PartialOrd for PathType
Source§impl PathOps for PathType
impl PathOps for PathType
type Output = PathAbs
Source§fn concat<P: AsRef<Path>>(&self, path: P) -> Result<Self::Output>
fn concat<P: AsRef<Path>>(&self, path: P) -> Result<Self::Output>
Returns a new value representing the concatenation of two paths. Read more
Source§fn join<P: AsRef<Path>>(&self, path: P) -> Self::Output
fn join<P: AsRef<Path>>(&self, path: P) -> Self::Output
An exact replica of
std::path::Path::join with all of its gotchas and pitfalls,, except
returns a more relevant type. Read moreimpl Eq for PathType
impl StructuralPartialEq for PathType
Auto Trait Implementations§
impl Freeze for PathType
impl RefUnwindSafe for PathType
impl Send for PathType
impl Sync for PathType
impl Unpin for PathType
impl UnwindSafe for PathType
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> PathInfo for T
impl<T> PathInfo for T
fn as_path(&self) -> &Path
fn to_arc_pathbuf(&self) -> Arc<PathBuf>
fn as_os_str(&self) -> &OsStr
fn to_str(&self) -> Option<&str>
fn to_string_lossy(&self) -> Cow<'_, str>
fn is_absolute(&self) -> bool
fn is_relative(&self) -> bool
fn has_root(&self) -> bool
fn ancestors(&self) -> Ancestors<'_>
fn file_name(&self) -> Option<&OsStr>
fn strip_prefix<P>(&self, base: P) -> Result<&Path, StripPrefixError>
fn starts_with<P: AsRef<Path>>(&self, base: P) -> bool
fn ends_with<P: AsRef<Path>>(&self, base: P) -> bool
fn file_stem(&self) -> Option<&OsStr>
fn extension(&self) -> Option<&OsStr>
fn components(&self) -> Components<'_>
fn iter(&self) -> Iter<'_>
fn display(&self) -> Display<'_>
Source§fn metadata(&self) -> Result<Metadata>
fn metadata(&self) -> Result<Metadata>
Queries the file system to get information about a file, directory, etc. Read more
Source§fn symlink_metadata(&self) -> Result<Metadata>
fn symlink_metadata(&self) -> Result<Metadata>
Queries the metadata about a file without following symlinks. Read more
fn exists(&self) -> bool
fn is_file(&self) -> bool
fn is_dir(&self) -> bool
Source§fn read_link(&self) -> Result<PathBuf>
fn read_link(&self) -> Result<PathBuf>
Reads a symbolic link, returning the path that the link points to. Read more