Struct path_abs::PathAbs
[−]
[src]
pub struct PathAbs(_);
An absolute (canonicalized) path that is guaranteed (when created) to exist.
Methods
impl PathAbs[src]
impl PathAbs[src]
fn new<P: AsRef<Path>>(path: P) -> Result<PathAbs>[src]
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").unwrap();
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 additinal 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").unwrap(); let src = lib.parent_dir().unwrap(); assert_eq!(PathDir::new("src").unwrap(), src);
fn mock<P: AsRef<Path>>(fake_path: P) -> PathAbs[src]
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").unwrap(); 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 = PathBuf>
fn as_path(&self) -> &Path1.0.0[src]
Coerces to a Path slice.
Examples
use std::path::{Path, PathBuf}; let p = PathBuf::from("/test"); assert_eq!(Path::new("/test"), p.as_path());
fn into_os_string(self) -> OsString1.0.0[src]
Consumes the PathBuf, yielding its internal OsString storage.
Examples
use std::path::PathBuf; let p = PathBuf::from("/the/head"); let os_str = p.into_os_string();
fn into_boxed_path(self) -> Box<Path>1.20.0[src]
Trait Implementations
impl Serialize for PathAbs[src]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
S: Serializer, [src]
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl<'de> Deserialize<'de> for PathAbs[src]
fn deserialize<D>(deserializer: D) -> Result<PathAbs, D::Error> where
D: Deserializer<'de>, [src]
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Clone for PathAbs[src]
fn clone(&self) -> PathAbs[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 PathAbs[src]
impl Hash for PathAbs[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 PathAbs[src]
fn eq(&self, __arg_0: &PathAbs) -> bool[src]
This method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, __arg_0: &PathAbs) -> bool[src]
This method tests for !=.
impl PartialOrd for PathAbs[src]
fn partial_cmp(&self, __arg_0: &PathAbs) -> Option<Ordering>[src]
This method returns an ordering between self and other values if one exists. Read more
fn lt(&self, __arg_0: &PathAbs) -> bool[src]
This method tests less than (for self and other) and is used by the < operator. Read more
fn le(&self, __arg_0: &PathAbs) -> 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: &PathAbs) -> bool[src]
This method tests greater than (for self and other) and is used by the > operator. Read more
fn ge(&self, __arg_0: &PathAbs) -> 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 PathAbs[src]
fn cmp(&self, __arg_0: &PathAbs) -> Ordering[src]
This method returns an Ordering between self and other. Read more
fn max(self, other: Self) -> Self1.22.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self1.22.0[src]
Compares and returns the minimum of two values. Read more