[−][src]Struct abscissa_core::path::AbsPath
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.
Methods
impl CanonicalPath
[src]
pub fn new<P>(path: &P) -> Result<&CanonicalPath, Error> where
P: AsRef<Path> + ?Sized,
[src]
P: AsRef<Path> + ?Sized,
Create a canonical path, returning error if the supplied path is not canonical
pub unsafe fn from_path_unchecked<P>(path: &P) -> &CanonicalPath where
P: AsRef<Path> + ?Sized,
[src]
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
.
pub fn to_canonical_path_buf(&self) -> CanonicalPathBuf
[src]
Convert a canonical path reference into an owned CanonicalPathBuf
pub fn as_path(&self) -> &Path
[src]
Return a Path
reference.
pub fn as_os_str(&self) -> &OsStr
[src]
Return an OsStr
reference.
pub fn to_str(&self) -> Option<&str>
[src]
Yields a &str
slice if the path is valid unicode.
pub fn parent(&self) -> Result<CanonicalPathBuf, Error>
[src]
Return a canonical parent path of this path, or io::Error
if the
path is the root directory or another canonicalization error occurs.
pub fn file_name(&self) -> Option<&OsStr>
[src]
Returns the final component of the path, if there is one.
pub fn starts_with<P>(&self, base: P) -> bool where
P: AsRef<Path>,
[src]
P: AsRef<Path>,
Determines whether base is a prefix of self.
pub fn ends_with<P>(&self, child: P) -> bool where
P: AsRef<Path>,
[src]
P: AsRef<Path>,
Determines whether child is a suffix of self.
pub fn file_stem(&self) -> Option<&OsStr>
[src]
Extracts the stem (non-extension) portion of self.file_name
.
pub fn extension(&self) -> Option<&OsStr>
[src]
Extracts the extension of self.file_name
, if possible.
pub fn with_file_name<S>(&self, file_name: S) -> Result<CanonicalPathBuf, Error> where
S: AsRef<OsStr>,
[src]
S: AsRef<OsStr>,
Creates an owned CanonicalPathBuf
like self but with the given file name.
pub fn with_extension<S>(&self, extension: S) -> Result<CanonicalPathBuf, Error> where
S: AsRef<OsStr>,
[src]
S: AsRef<OsStr>,
Creates an owned CanonicalPathBuf
like self but with the given extension.
pub fn components(&self) -> Components
[src]
Produces an iterator over the Component
s of a path
pub fn iter(&self) -> Iter
[src]
Produces an iterator over the path's components viewed as
OsStr
slices.
pub fn display(&self) -> Display
[src]
Returns an object that implements Display
for safely printing
paths that may contain non-Unicode data.
pub fn metadata(&self) -> Result<Metadata, Error>
[src]
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.
pub fn join<P>(&self, path: P) -> Result<CanonicalPathBuf, Error> where
P: AsRef<Path>,
[src]
P: AsRef<Path>,
Join a path onto a canonical path, returning a CanonicalPathBuf
.
pub fn read_dir(&self) -> Result<ReadDir, Error>
[src]
Returns an iterator over the entries within a directory.
The iterator will yield instances of io::Result
This is an alias to fs::read_dir.
pub fn exists(&self) -> bool
[src]
Does this path exist?
pub fn is_file(&self) -> bool
[src]
Is this path a file?
pub fn is_dir(&self) -> bool
[src]
Is this path a directory?
Trait Implementations
impl Borrow<CanonicalPath> for CanonicalPathBuf
[src]
fn borrow(&self) -> &CanonicalPath
[src]
impl PartialEq<CanonicalPath> for CanonicalPath
[src]
fn eq(&self, other: &CanonicalPath) -> bool
[src]
fn ne(&self, other: &CanonicalPath) -> bool
[src]
impl Debug for CanonicalPath
[src]
impl Ord for CanonicalPath
[src]
fn cmp(&self, other: &CanonicalPath) -> 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 PartialOrd<CanonicalPath> for CanonicalPath
[src]
fn partial_cmp(&self, other: &CanonicalPath) -> Option<Ordering>
[src]
fn lt(&self, other: &CanonicalPath) -> bool
[src]
fn le(&self, other: &CanonicalPath) -> bool
[src]
fn gt(&self, other: &CanonicalPath) -> bool
[src]
fn ge(&self, other: &CanonicalPath) -> bool
[src]
impl AsRef<CanonicalPath> for CanonicalPathBuf
[src]
fn as_ref(&self) -> &CanonicalPath
[src]
impl AsRef<Path> for CanonicalPath
[src]
impl Eq for CanonicalPath
[src]
impl Hash for CanonicalPath
[src]
fn hash<__H>(&self, state: &mut __H) where
__H: Hasher,
[src]
__H: Hasher,
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 ToOwned for CanonicalPath
[src]
type Owned = CanonicalPathBuf
The resulting type after obtaining ownership.
fn to_owned(&self) -> CanonicalPathBuf
[src]
fn clone_into(&self, target: &mut Self::Owned)
[src]
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
Auto Trait Implementations
impl Sync for CanonicalPath
impl Send for CanonicalPath
impl Unpin for CanonicalPath
impl RefUnwindSafe for CanonicalPath
impl UnwindSafe for CanonicalPath
Blanket Implementations
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> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,