Struct abscissa_core::path::AbsPathBuf
source · pub struct AbsPathBuf(_);
Expand description
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.
Implementations§
source§impl CanonicalPathBuf
impl CanonicalPathBuf
sourcepub fn canonicalize<P>(path: P) -> Result<CanonicalPathBuf, Error>where
P: AsRef<Path>,
pub fn canonicalize<P>(path: P) -> Result<CanonicalPathBuf, Error>where
P: AsRef<Path>,
Create a canonical path by first canonicalizing the given path.
sourcepub fn new<P>(path: P) -> Result<CanonicalPathBuf, Error>where
P: AsRef<Path>,
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.
sourcepub fn as_canonical_path(&self) -> &CanonicalPath
pub fn as_canonical_path(&self) -> &CanonicalPath
Return a CanonicalPath
reference.
sourcepub fn set_file_name<S>(&mut self, file_name: S)where
S: AsRef<OsStr>,
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
sourcepub fn set_extension<S>(&mut self, extension: S) -> boolwhere
S: AsRef<OsStr>,
pub fn set_extension<S>(&mut self, extension: S) -> boolwhere
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.
sourcepub fn into_path_buf(self) -> PathBuf
pub fn into_path_buf(self) -> PathBuf
Consumes the CanonicalPathBuf
, yielding its internal PathBuf
storage.
sourcepub fn into_os_string(self) -> OsString
pub fn into_os_string(self) -> OsString
Consumes the CanonicalPathBuf
, yielding its internal OsString
storage.
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) -> boolwhere
P: AsRef<Path>,
pub fn starts_with<P>(&self, base: P) -> boolwhere
P: AsRef<Path>,
Determines whether base is a prefix of self.
sourcepub fn ends_with<P>(&self, child: P) -> boolwhere
P: AsRef<Path>,
pub fn ends_with<P>(&self, child: P) -> boolwhere
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§
source§impl AsRef<CanonicalPath> for CanonicalPathBuf
impl AsRef<CanonicalPath> for CanonicalPathBuf
source§fn as_ref(&self) -> &CanonicalPath
fn as_ref(&self) -> &CanonicalPath
source§impl AsRef<OsStr> for CanonicalPathBuf
impl AsRef<OsStr> for CanonicalPathBuf
source§impl AsRef<Path> for CanonicalPathBuf
impl AsRef<Path> for CanonicalPathBuf
source§impl Borrow<CanonicalPath> for CanonicalPathBuf
impl Borrow<CanonicalPath> for CanonicalPathBuf
source§fn borrow(&self) -> &CanonicalPath
fn borrow(&self) -> &CanonicalPath
source§impl Clone for CanonicalPathBuf
impl Clone for CanonicalPathBuf
source§fn clone(&self) -> CanonicalPathBuf
fn clone(&self) -> CanonicalPathBuf
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for CanonicalPathBuf
impl Debug for CanonicalPathBuf
source§impl Hash for CanonicalPathBuf
impl Hash for CanonicalPathBuf
source§impl Ord for CanonicalPathBuf
impl Ord for CanonicalPathBuf
source§fn cmp(&self, other: &CanonicalPathBuf) -> Ordering
fn cmp(&self, other: &CanonicalPathBuf) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<CanonicalPathBuf> for CanonicalPathBuf
impl PartialEq<CanonicalPathBuf> for CanonicalPathBuf
source§fn eq(&self, other: &CanonicalPathBuf) -> bool
fn eq(&self, other: &CanonicalPathBuf) -> bool
source§impl PartialOrd<CanonicalPathBuf> for CanonicalPathBuf
impl PartialOrd<CanonicalPathBuf> for CanonicalPathBuf
source§fn partial_cmp(&self, other: &CanonicalPathBuf) -> Option<Ordering>
fn partial_cmp(&self, other: &CanonicalPathBuf) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl Eq for CanonicalPathBuf
impl StructuralEq for CanonicalPathBuf
impl StructuralPartialEq for CanonicalPathBuf
Auto Trait Implementations§
impl RefUnwindSafe for CanonicalPathBuf
impl Send for CanonicalPathBuf
impl Sync for CanonicalPathBuf
impl Unpin for CanonicalPathBuf
impl UnwindSafe for CanonicalPathBuf
Blanket Implementations§
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_yellow<'a>(&'a self) -> BgColorDisplay<'a, Yellow, Self>
fn on_yellow<'a>(&'a self) -> BgColorDisplay<'a, Yellow, Self>
§fn magenta<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>
fn magenta<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>
§fn on_magenta<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn on_magenta<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
§fn on_purple<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn on_purple<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
§fn default_color<'a>(&'a self) -> FgColorDisplay<'a, Default, Self>
fn default_color<'a>(&'a self) -> FgColorDisplay<'a, Default, Self>
§fn on_default_color<'a>(&'a self) -> BgColorDisplay<'a, Default, Self>
fn on_default_color<'a>(&'a self) -> BgColorDisplay<'a, Default, Self>
§fn bright_black<'a>(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>
fn bright_black<'a>(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>
§fn on_bright_black<'a>(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>
fn on_bright_black<'a>(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>
§fn bright_red<'a>(&'a self) -> FgColorDisplay<'a, BrightRed, Self>
fn bright_red<'a>(&'a self) -> FgColorDisplay<'a, BrightRed, Self>
§fn on_bright_red<'a>(&'a self) -> BgColorDisplay<'a, BrightRed, Self>
fn on_bright_red<'a>(&'a self) -> BgColorDisplay<'a, BrightRed, Self>
§fn bright_green<'a>(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>
fn bright_green<'a>(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>
§fn on_bright_green<'a>(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>
fn on_bright_green<'a>(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>
§fn bright_yellow<'a>(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>
fn bright_yellow<'a>(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>
§fn on_bright_yellow<'a>(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>
fn on_bright_yellow<'a>(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>
§fn bright_blue<'a>(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>
fn bright_blue<'a>(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>
§fn on_bright_blue<'a>(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>
fn on_bright_blue<'a>(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>
§fn bright_magenta<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn bright_magenta<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
§fn on_bright_magenta<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_magenta<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
§fn bright_purple<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn bright_purple<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
§fn on_bright_purple<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_purple<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
§fn bright_cyan<'a>(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>
fn bright_cyan<'a>(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>
§fn on_bright_cyan<'a>(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>
fn on_bright_cyan<'a>(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>
§fn bright_white<'a>(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>
fn bright_white<'a>(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>
§fn on_bright_white<'a>(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>
fn on_bright_white<'a>(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>
§fn blink_fast<'a>(&'a self) -> BlinkFastDisplay<'a, Self>
fn blink_fast<'a>(&'a self) -> BlinkFastDisplay<'a, Self>
§fn strikethrough<'a>(&'a self) -> StrikeThroughDisplay<'a, Self>
fn strikethrough<'a>(&'a self) -> StrikeThroughDisplay<'a, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg
or
a color-specific method, such as OwoColorize::green
, Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg
or
a color-specific method, such as OwoColorize::on_yellow
, Read more