Struct path_abs::PathAbs[][src]

pub struct PathAbs(_);

An absolute (not necessarily canonicalized) path that may or may not exist.

Implementations

impl PathAbs[src]

pub fn new<P: AsRef<Path>>(path: P) -> Result<PathAbs>[src]

Construct an absolute path from an arbitrary (absolute or relative) one.

This is different from canonicalize in that it preserves symlinks and the destination may or may not exist.

This function will:

  • Resolve relative paths against the current working directory.
  • Strip any . components (/a/./c -> /a/c)
  • Resolve .. semantically (not using the file system). So, a/b/c/../d => a/b/d will always be true regardless of symlinks. If you want symlinks correctly resolved, use canonicalize() instead.

On windows, this will sometimes call canonicalize() on the first component to guarantee it is the correct canonicalized prefix. For paths starting with root it also has to get the current_dir

On linux, the only syscall this will make is to get the current_dir for relative paths.

Examples

use path_abs::{PathAbs, PathInfo};

let lib = PathAbs::new("src/lib.rs")?;

assert_eq!(lib.is_absolute(), true);

pub fn new_unchecked<P: Into<Arc<PathBuf>>>(path: P) -> PathAbs[src]

Create a PathAbs unchecked.

This is mostly used for constructing during tests, or if the path was previously validated. This is effectively the same as a Arc<PathBuf>.

Note: This is memory safe, so is not marked unsafe. However, it could cause panics in some methods if the path was not properly validated.

pub fn as_path(&self) -> &Path[src]

Return a reference to a basic std::path::Path

Trait Implementations

impl AsRef<OsStr> for PathAbs[src]

impl AsRef<Path> for PathAbs[src]

impl AsRef<PathAbs> for PathDir[src]

impl AsRef<PathAbs> for PathFile[src]

impl AsRef<PathAbs> for PathType[src]

impl AsRef<PathBuf> for PathAbs[src]

impl Borrow<Path> for PathAbs[src]

impl<'a> Borrow<Path> for &'a PathAbs[src]

impl Borrow<PathAbs> for PathDir[src]

impl<'a> Borrow<PathAbs> for &'a PathDir[src]

impl Borrow<PathAbs> for PathFile[src]

impl<'a> Borrow<PathAbs> for &'a PathFile[src]

impl Borrow<PathAbs> for PathType[src]

impl<'a> Borrow<PathAbs> for &'a PathType[src]

impl Borrow<PathBuf> for PathAbs[src]

impl<'a> Borrow<PathBuf> for &'a PathAbs[src]

impl Clone for PathAbs[src]

impl Debug for PathAbs[src]

impl<'de> Deserialize<'de> for PathAbs[src]

impl Eq for PathAbs[src]

impl From<PathDir> for PathAbs[src]

impl From<PathFile> for PathAbs[src]

impl From<PathType> for PathAbs[src]

impl Hash for PathAbs[src]

impl Ord for PathAbs[src]

impl PartialEq<PathAbs> for PathAbs[src]

impl PartialOrd<PathAbs> for PathAbs[src]

impl PathMut for PathAbs[src]

impl PathOps for PathAbs[src]

type Output = PathAbs

impl Serialize for PathAbs[src]

impl StructuralEq for PathAbs[src]

impl StructuralPartialEq for PathAbs[src]

Auto Trait Implementations

impl RefUnwindSafe for PathAbs

impl Send for PathAbs

impl Sync for PathAbs

impl Unpin for PathAbs

impl UnwindSafe for PathAbs

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> PathInfo for T where
    T: Clone + Borrow<PathBuf> + Into<Arc<PathBuf>>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToStfu8 for T where
    T: Borrow<PathBuf>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.