[−][src]Struct path_abs::PathAbs
An absolute (not necessarily canonicalized) path that may or may not exist.
Methods
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, usecanonicalize()
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 thecurrent_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 PathMut for PathAbs
[src]
fn append<P: AsRef<Path>>(&mut self, path: P) -> Result<()>
[src]
fn pop_up(&mut self) -> Result<()>
[src]
fn truncate_to_root(&mut self)
[src]
fn set_file_name<S: AsRef<OsStr>>(&mut self, file_name: S)
[src]
fn set_extension<S: AsRef<OsStr>>(&mut self, extension: S) -> bool
[src]
impl PathOps for PathAbs
[src]
type Output = PathAbs
fn concat<P: AsRef<Path>>(&self, path: P) -> Result<Self::Output>
[src]
fn join<P: AsRef<Path>>(&self, path: P) -> Self::Output
[src]
fn with_file_name<S: AsRef<OsStr>>(&self, file_name: S) -> Self::Output
[src]
fn with_extension<S: AsRef<OsStr>>(&self, extension: S) -> Self::Output
[src]
impl From<PathAbs> for Arc<PathBuf>
[src]
impl From<PathAbs> for PathBuf
[src]
impl From<PathDir> for PathAbs
[src]
impl From<PathFile> for PathAbs
[src]
impl From<PathType> for PathAbs
[src]
impl PartialEq<PathAbs> for PathAbs
[src]
impl Clone for PathAbs
[src]
fn clone(&self) -> PathAbs
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl AsRef<OsStr> for PathAbs
[src]
impl AsRef<Path> for PathAbs
[src]
impl AsRef<PathBuf> for PathAbs
[src]
impl AsRef<PathAbs> for PathDir
[src]
impl AsRef<PathAbs> for PathFile
[src]
impl AsRef<PathAbs> for PathType
[src]
impl PartialOrd<PathAbs> for PathAbs
[src]
fn partial_cmp(&self, other: &PathAbs) -> Option<Ordering>
[src]
fn lt(&self, other: &PathAbs) -> bool
[src]
fn le(&self, other: &PathAbs) -> bool
[src]
fn gt(&self, other: &PathAbs) -> bool
[src]
fn ge(&self, other: &PathAbs) -> bool
[src]
impl Eq for PathAbs
[src]
impl Ord for PathAbs
[src]
fn cmp(&self, other: &PathAbs) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
fn clamp(self, min: Self, max: Self) -> Self
[src]
clamp
)Restrict a value to a certain interval. Read more
impl Debug for PathAbs
[src]
impl Hash for PathAbs
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
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 Borrow<Path> for PathAbs
[src]
impl Borrow<PathBuf> for PathAbs
[src]
impl<'a> Borrow<Path> for &'a PathAbs
[src]
impl<'a> Borrow<PathBuf> 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 Serialize for PathAbs
[src]
impl<'de> Deserialize<'de> for PathAbs
[src]
fn deserialize<D>(deserializer: D) -> Result<PathAbs, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
Auto Trait Implementations
impl Unpin for PathAbs
impl Sync for PathAbs
impl Send for PathAbs
impl RefUnwindSafe for PathAbs
impl UnwindSafe for PathAbs
Blanket Implementations
impl<T> ToStfu8 for T where
T: Borrow<PathBuf>,
[src]
T: Borrow<PathBuf>,
impl<T> PathInfo for T where
T: Clone + Borrow<PathBuf> + Into<Arc<PathBuf>>,
[src]
T: Clone + Borrow<PathBuf> + Into<Arc<PathBuf>>,
fn as_path(&Self) -> &Path
[src]
fn to_arc_pathbuf(&Self) -> Arc<PathBuf>
[src]
fn as_os_str(&self) -> &OsStr
[src]
fn to_str(&self) -> Option<&str>
[src]
fn to_string_lossy(&self) -> Cow<str>
[src]
fn is_absolute(&self) -> bool
[src]
fn is_relative(&self) -> bool
[src]
fn has_root(&self) -> bool
[src]
fn ancestors(&self) -> Ancestors
[src]
fn file_name(&self) -> Option<&OsStr>
[src]
fn strip_prefix<P>(&self, base: P) -> Result<&Path, StripPrefixError> where
P: AsRef<Path>,
[src]
P: AsRef<Path>,
fn starts_with<P: AsRef<Path>>(&self, base: P) -> bool
[src]
fn ends_with<P: AsRef<Path>>(&self, base: P) -> bool
[src]
fn file_stem(&self) -> Option<&OsStr>
[src]
fn extension(&self) -> Option<&OsStr>
[src]
fn components(&self) -> Components
[src]
fn iter(&self) -> Iter
[src]
fn display(&self) -> Display
[src]
fn metadata(&self) -> Result<Metadata>
[src]
Queries the file system to get information about a file, directory, etc. Read more
fn symlink_metadata(&self) -> Result<Metadata>
[src]
Queries the metadata about a file without following symlinks. Read more
fn exists(&self) -> bool
[src]
fn is_file(&self) -> bool
[src]
fn is_dir(&self) -> bool
[src]
fn read_link(&self) -> Result<PathBuf>
[src]
Reads a symbolic link, returning the path that the link points to. Read more
fn canonicalize(&self) -> Result<PathAbs>
[src]
Returns the canonical, absolute form of the path with all intermediate components normalized and symbolic links resolved. Read more
fn parent(&self) -> Result<&Path>
[src]
Returns the path without its final component, if there is one. Read more
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,