Struct abscissa::util::CanonicalPathBuf [−][src]
pub struct CanonicalPathBuf(_);
An owned path on the filesystem which is guaranteed to be canonical.
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 CanonicalPathBuf
[src]
impl CanonicalPathBuf
pub fn canonicalize<P>(path: P) -> Result<CanonicalPathBuf, Error> where
P: AsRef<Path>,
[src]
pub fn canonicalize<P>(path: P) -> Result<CanonicalPathBuf, Error> where
P: AsRef<Path>,
Create a canonical path by first canonicalizing the given path.
pub fn new<P>(path: P) -> Result<CanonicalPathBuf, Error> where
P: AsRef<Path>,
[src]
pub fn new<P>(path: P) -> Result<CanonicalPathBuf, Error> where
P: AsRef<Path>,
Create a canonical path, returning error if the supplied path is not canonical.
pub fn as_canonical_path(&self) -> &CanonicalPath
[src]
pub fn as_canonical_path(&self) -> &CanonicalPath
Return a CanonicalPath
reference.
pub fn set_file_name<S>(&mut self, file_name: S) where
S: AsRef<OsStr>,
[src]
pub fn set_file_name<S>(&mut self, file_name: S) where
S: AsRef<OsStr>,
Updates self
's filename ala the same method on PathBuf
pub fn set_extension<S>(&mut self, extension: S) -> bool where
S: AsRef<OsStr>,
[src]
pub fn set_extension<S>(&mut self, extension: S) -> bool where
S: AsRef<OsStr>,
Updates self.extension
to extension.
Returns false
and does nothing if self.file_name
is None
,
returns true
and updates the extension otherwise.
If self.extension
is None
, the extension is added; otherwise it is replaced.
pub fn into_path_buf(self) -> PathBuf
[src]
pub fn into_path_buf(self) -> PathBuf
Consumes the CanonicalPathBuf
, yielding its internal PathBuf
storage.
pub fn into_os_string(self) -> OsString
[src]
pub fn into_os_string(self) -> OsString
Consumes the CanonicalPathBuf
, yielding its internal OsString
storage.
pub fn as_path(&self) -> &Path
[src]
pub fn as_path(&self) -> &Path
Return a Path
reference.
pub fn as_os_str(&self) -> &OsStr
[src]
pub fn as_os_str(&self) -> &OsStr
Return an OsStr
reference.
pub fn to_str(&self) -> Option<&str>
[src]
pub fn to_str(&self) -> Option<&str>
Yields a &str
slice if the path is valid unicode.
pub fn parent(&self) -> Result<CanonicalPathBuf, Error>
[src]
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.
pub fn file_name(&self) -> Option<&OsStr>
[src]
pub fn file_name(&self) -> Option<&OsStr>
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]
pub fn starts_with<P>(&self, base: P) -> bool where
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]
pub fn ends_with<P>(&self, child: P) -> bool where
P: AsRef<Path>,
Determines whether child is a suffix of self.
pub fn file_stem(&self) -> Option<&OsStr>
[src]
pub fn file_stem(&self) -> Option<&OsStr>
Extracts the stem (non-extension) portion of self.file_name
.
pub fn extension(&self) -> Option<&OsStr>
[src]
pub fn extension(&self) -> Option<&OsStr>
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]
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.
pub fn with_extension<S>(&self, extension: S) -> Result<CanonicalPathBuf, Error> where
S: AsRef<OsStr>,
[src]
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.
ⓘImportant traits for Components<'a>pub fn components(&self) -> Components
[src]
pub fn components(&self) -> Components
Produces an iterator over the Component
s of a path
ⓘImportant traits for Iter<'a>pub fn iter(&self) -> Iter
[src]
pub fn iter(&self) -> Iter
Produces an iterator over the path's components viewed as
OsStr
slices.
pub fn display(&self) -> Display
[src]
pub fn display(&self) -> Display
Returns an object that implements Display
for safely printing
paths that may contain non-Unicode data.
pub fn metadata(&self) -> Result<Metadata, Error>
[src]
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.
pub fn join<P>(&self, path: P) -> Result<CanonicalPathBuf, Error> where
P: AsRef<Path>,
[src]
pub fn join<P>(&self, path: P) -> Result<CanonicalPathBuf, Error> where
P: AsRef<Path>,
Join a path onto a canonical path, returning a CanonicalPathBuf
.
pub fn read_dir(&self) -> Result<ReadDir, Error>
[src]
pub fn read_dir(&self) -> Result<ReadDir, Error>
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]
pub fn exists(&self) -> bool
Does this path exist?
pub fn is_file(&self) -> bool
[src]
pub fn is_file(&self) -> bool
Is this path a file?
pub fn is_dir(&self) -> bool
[src]
pub fn is_dir(&self) -> bool
Is this path a directory?
Trait Implementations
impl PartialOrd<CanonicalPathBuf> for CanonicalPathBuf
[src]
impl PartialOrd<CanonicalPathBuf> for CanonicalPathBuf
fn partial_cmp(&self, other: &CanonicalPathBuf) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &CanonicalPathBuf) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &CanonicalPathBuf) -> bool
[src]
fn lt(&self, other: &CanonicalPathBuf) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &CanonicalPathBuf) -> bool
[src]
fn le(&self, other: &CanonicalPathBuf) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &CanonicalPathBuf) -> bool
[src]
fn gt(&self, other: &CanonicalPathBuf) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &CanonicalPathBuf) -> bool
[src]
fn ge(&self, other: &CanonicalPathBuf) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Hash for CanonicalPathBuf
[src]
impl Hash for CanonicalPathBuf
fn hash<__H>(&self, state: &mut __H) where
__H: Hasher,
[src]
fn hash<__H>(&self, state: &mut __H) where
__H: Hasher,
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]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl Borrow<CanonicalPath> for CanonicalPathBuf
[src]
impl Borrow<CanonicalPath> for CanonicalPathBuf
fn borrow(&self) -> &CanonicalPath
[src]
fn borrow(&self) -> &CanonicalPath
Immutably borrows from an owned value. Read more
impl Clone for CanonicalPathBuf
[src]
impl Clone for CanonicalPathBuf
fn clone(&self) -> CanonicalPathBuf
[src]
fn clone(&self) -> CanonicalPathBuf
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for CanonicalPathBuf
[src]
impl Debug for CanonicalPathBuf
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
Formats the value using the given formatter. Read more
impl Ord for CanonicalPathBuf
[src]
impl Ord for CanonicalPathBuf
fn cmp(&self, other: &CanonicalPathBuf) -> Ordering
[src]
fn cmp(&self, other: &CanonicalPathBuf) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl AsRef<CanonicalPath> for CanonicalPathBuf
[src]
impl AsRef<CanonicalPath> for CanonicalPathBuf
fn as_ref(&self) -> &CanonicalPath
[src]
fn as_ref(&self) -> &CanonicalPath
Performs the conversion.
impl AsRef<OsStr> for CanonicalPathBuf
[src]
impl AsRef<OsStr> for CanonicalPathBuf
impl AsRef<Path> for CanonicalPathBuf
[src]
impl AsRef<Path> for CanonicalPathBuf
impl Eq for CanonicalPathBuf
[src]
impl Eq for CanonicalPathBuf
impl PartialEq<CanonicalPathBuf> for CanonicalPathBuf
[src]
impl PartialEq<CanonicalPathBuf> for CanonicalPathBuf
fn eq(&self, other: &CanonicalPathBuf) -> bool
[src]
fn eq(&self, other: &CanonicalPathBuf) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &CanonicalPathBuf) -> bool
[src]
fn ne(&self, other: &CanonicalPathBuf) -> bool
This method tests for !=
.
Auto Trait Implementations
impl Send for CanonicalPathBuf
impl Send for CanonicalPathBuf
impl Sync for CanonicalPathBuf
impl Sync for CanonicalPathBuf