Struct ergo_fs::PathAbs
[−]
[src]
pub struct PathAbs(_);
An absolute (canonicalized) path that is guaranteed (when created) to exist.
Methods
impl PathAbs
[src]
fn new<P>(path: P) -> Result<PathAbs, Error> where
P: AsRef<Path>,
[src]
P: AsRef<Path>,
Instantiate a new PathAbs
. The path must exist or io::Error
will be returned.
Examples
use path_abs::PathAbs; let lib = PathAbs::new("src/lib.rs")?;
fn into_file(self) -> Result<PathFile, Error>
[src]
Resolve the PathAbs
as a PathFile
. Return an error if it is not a file.
fn into_dir(self) -> Result<PathDir, Error>
[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
fn mock<P>(fake_path: P) -> PathAbs where
P: AsRef<Path>,
[src]
P: AsRef<Path>,
For constructing mocked paths during tests. This is effectively the same as a PathBuf
.
This is NOT checked for validity so the file may or may not actually exist and will NOT be, in any way, an absolute or canonicalized path.
Examples
use path_abs::PathAbs; // this file exist let lib = PathAbs::new("src/lib.rs")?; let lib_mocked = PathAbs::mock("src/lib.rs"); // in this case, the mocked file exists assert!(lib_mocked.exists()); // However, it is NOT equivalent to `lib` assert_ne!(lib, lib_mocked); // this file doesn't exist at all let dne = PathAbs::mock("src/dne.rs"); assert!(!dne.exists());
Methods from Deref<Target = PathArc>
fn join<P>(&self, path: P) -> PathArc where
P: AsRef<Path>,
[src]
P: AsRef<Path>,
Creates an owned PathBuf with path adjoined to self.
This function is identical to std::path::PathBuf::join except
it returns PathArc
instead of PathBuf
fn with_file_name<P>(&self, file_name: P) -> PathArc where
P: AsRef<OsStr>,
[src]
P: AsRef<OsStr>,
Creates an owned PathArc
like self but with the given file name.
This function is identical to std::path::PathBuf::with_file_name except
it returns PathArc
instead of PathBuf
fn with_extension<P>(&self, extension: P) -> PathArc where
P: AsRef<OsStr>,
[src]
P: AsRef<OsStr>,
Creates an owned PathArc
like self but with the given extension.
This function is identical to std::path::PathBuf::with_extension except
it returns PathArc
instead of PathBuf
fn metadata(&self) -> Result<Metadata, Error>
[src]
Queries the file system to get information about a file, directory, etc.
This function will traverse symbolic links to query information about the destination file.
This function is identical to std::path::Path::metadata except it has error messages which include the action and the path
fn symlink_metadata(&self) -> Result<Metadata, Error>
[src]
Queries the metadata about a file without following symlinks.
This function is identical to std::path::Path::symlink_metadata except it has error messages which include the action and the path
fn canonicalize(&self) -> Result<PathAbs, Error>
[src]
Returns the canonical form of the path with all intermediate components normalized and symbolic links resolved.
This is identical to
PathAbs::new(path)
.
This function is identical to std::path::Path::canonicalize except:
- It returns a PathAbs
object
- It has error messages which include the action and the path
fn read_link(&self) -> Result<PathArc, Error>
[src]
Reads a symbolic link, returning the file that the link points to.
This function is identical to std::path::Path::read_link except:
- It returns a PathArc
object instead of PathBuf
- It has error messages which include the action and the path
fn read_dir(&self) -> Result<ListDir, Error>
[src]
Returns an iterator over the entries within a directory.
This function is a shortcut to PathDir::list
. It is slightly different
than std::path::Path::read_dir.
fn as_path(&self) -> &Path
[src]
Return a reference to a basic std::path::Path
Trait Implementations
impl Serialize for PathAbs
[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 PathAbs
[src]
impl Hash for PathAbs
[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 PathAbs
[src]
impl Eq for PathAbs
[src]
impl Deref for PathAbs
[src]
type Target = PathArc
The resulting type after dereferencing.
fn deref(&self) -> &PathArc
[src]
Dereferences the value.
impl AsRef<PathArc> for PathAbs
[src]
impl PartialEq<PathAbs> for PathAbs
[src]
impl Debug for PathAbs
[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
[src]
Formats the value using the given formatter.
impl<'de> Deserialize<'de> for PathAbs
[src]
fn deserialize<D>(
deserializer: D
) -> Result<PathAbs, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
[src]
deserializer: D
) -> Result<PathAbs, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,