Struct abscissa_core::path::AbsPath
source · [−]pub struct AbsPath(_);
Expand description
A reference type for a canonical filesystem path
More specifically: it is at least guaranteed to be canonical at the time it is created. There are potential TOCTTOU problems if the underlying filesystem structure changes after path canonicalization.
Implementations
sourceimpl CanonicalPath
impl CanonicalPath
sourcepub fn new<P>(path: &P) -> Result<&CanonicalPath, Error> where
P: AsRef<Path> + ?Sized,
pub fn new<P>(path: &P) -> Result<&CanonicalPath, Error> where
P: AsRef<Path> + ?Sized,
Create a canonical path, returning error if the supplied path is not canonical
sourcepub unsafe fn from_path_unchecked<P>(path: &P) -> &CanonicalPath where
P: AsRef<Path> + ?Sized,
pub unsafe fn from_path_unchecked<P>(path: &P) -> &CanonicalPath where
P: AsRef<Path> + ?Sized,
Create a canonical path from a path, skipping the canonicalization check
This uses the same unsafe reference conversion tricks as std
to
convert from AsRef<Path>
to AsRef<CanonicalPath>
, i.e. &CanonicalPath
is a newtype for &Path
in the same way &Path
is a newtype for &OsStr
.
sourcepub fn to_canonical_path_buf(&self) -> CanonicalPathBuf
pub fn to_canonical_path_buf(&self) -> CanonicalPathBuf
Convert a canonical path reference into an owned CanonicalPathBuf
sourcepub fn parent(&self) -> Result<CanonicalPathBuf, Error>
pub fn parent(&self) -> Result<CanonicalPathBuf, Error>
Return a canonical parent path of this path, or io::Error
if the
path is the root directory or another canonicalization error occurs.
sourcepub fn file_name(&self) -> Option<&OsStr>
pub fn file_name(&self) -> Option<&OsStr>
Returns the final component of the path, if there is one.
sourcepub fn starts_with<P>(&self, base: P) -> bool where
P: AsRef<Path>,
pub fn starts_with<P>(&self, base: P) -> bool where
P: AsRef<Path>,
Determines whether base is a prefix of self.
sourcepub fn ends_with<P>(&self, child: P) -> bool where
P: AsRef<Path>,
pub fn ends_with<P>(&self, child: P) -> bool where
P: AsRef<Path>,
Determines whether child is a suffix of self.
sourcepub fn file_stem(&self) -> Option<&OsStr>
pub fn file_stem(&self) -> Option<&OsStr>
Extracts the stem (non-extension) portion of self.file_name
.
sourcepub fn extension(&self) -> Option<&OsStr>
pub fn extension(&self) -> Option<&OsStr>
Extracts the extension of self.file_name
, if possible.
sourcepub fn with_file_name<S>(&self, file_name: S) -> Result<CanonicalPathBuf, Error> where
S: AsRef<OsStr>,
pub fn with_file_name<S>(&self, file_name: S) -> Result<CanonicalPathBuf, Error> where
S: AsRef<OsStr>,
Creates an owned CanonicalPathBuf
like self but with the given file name.
sourcepub fn with_extension<S>(&self, extension: S) -> Result<CanonicalPathBuf, Error> where
S: AsRef<OsStr>,
pub fn with_extension<S>(&self, extension: S) -> Result<CanonicalPathBuf, Error> where
S: AsRef<OsStr>,
Creates an owned CanonicalPathBuf
like self but with the given extension.
sourcepub fn components(&self) -> Components<'_>
pub fn components(&self) -> Components<'_>
Produces an iterator over the Component
s of a path
sourcepub fn iter(&self) -> Iter<'_>
pub fn iter(&self) -> Iter<'_>
Produces an iterator over the path’s components viewed as
OsStr
slices.
sourcepub fn display(&self) -> Display<'_>
pub fn display(&self) -> Display<'_>
Returns an object that implements Display
for safely printing
paths that may contain non-Unicode data.
sourcepub fn metadata(&self) -> Result<Metadata, Error>
pub fn metadata(&self) -> Result<Metadata, Error>
Queries the file system to get information about a file, directory, etc.
Unlike the std
version of this method, it will not follow symlinks,
since as a canonical path we should be symlink-free.
sourcepub fn join<P>(&self, path: P) -> Result<CanonicalPathBuf, Error> where
P: AsRef<Path>,
pub fn join<P>(&self, path: P) -> Result<CanonicalPathBuf, Error> where
P: AsRef<Path>,
Join a path onto a canonical path, returning a CanonicalPathBuf
.
Trait Implementations
sourceimpl AsRef<CanonicalPath> for CanonicalPathBuf
impl AsRef<CanonicalPath> for CanonicalPathBuf
sourcepub fn as_ref(&self) -> &CanonicalPath
pub fn as_ref(&self) -> &CanonicalPath
Performs the conversion.
sourceimpl Borrow<CanonicalPath> for CanonicalPathBuf
impl Borrow<CanonicalPath> for CanonicalPathBuf
sourcepub fn borrow(&self) -> &CanonicalPath
pub fn borrow(&self) -> &CanonicalPath
Immutably borrows from an owned value. Read more
sourceimpl Debug for CanonicalPath
impl Debug for CanonicalPath
sourceimpl Hash for CanonicalPath
impl Hash for CanonicalPath
sourceimpl Ord for CanonicalPath
impl Ord for CanonicalPath
sourceimpl PartialEq<CanonicalPath> for CanonicalPath
impl PartialEq<CanonicalPath> for CanonicalPath
sourcepub fn eq(&self, other: &CanonicalPath) -> bool
pub fn eq(&self, other: &CanonicalPath) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcepub fn ne(&self, other: &CanonicalPath) -> bool
pub fn ne(&self, other: &CanonicalPath) -> bool
This method tests for !=
.
sourceimpl PartialOrd<CanonicalPath> for CanonicalPath
impl PartialOrd<CanonicalPath> for CanonicalPath
sourcepub fn partial_cmp(&self, other: &CanonicalPath) -> Option<Ordering>
pub fn partial_cmp(&self, other: &CanonicalPath) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl ToOwned for CanonicalPath
impl ToOwned for CanonicalPath
type Owned = CanonicalPathBuf
type Owned = CanonicalPathBuf
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> CanonicalPathBuf
pub fn to_owned(&self) -> CanonicalPathBuf
Creates owned data from borrowed data, usually by cloning. Read more
sourcefn clone_into(&self, target: &mut Self::Owned)
fn clone_into(&self, target: &mut Self::Owned)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl Eq for CanonicalPath
impl StructuralEq for CanonicalPath
impl StructuralPartialEq for CanonicalPath
Auto Trait Implementations
impl RefUnwindSafe for CanonicalPath
impl Send for CanonicalPath
impl !Sized for CanonicalPath
impl Sync for CanonicalPath
impl Unpin for CanonicalPath
impl UnwindSafe for CanonicalPath
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcepub fn equivalent(&self, key: &K) -> bool
pub fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.