pub struct PathBuf { /* private fields */ }Expand description
Path to an item in a library, i.e. module, procedure, constant or type.
Implementations§
Source§impl PathBuf
Constructors
impl PathBuf
Constructors
Sourcepub fn with_capacity(capacity: usize) -> PathBuf
pub fn with_capacity(capacity: usize) -> PathBuf
Get an empty PathBuf with capacity bytes allocated for the underlying path storage
Sourcepub fn new<S>(source: &S) -> Result<PathBuf, PathError>
pub fn new<S>(source: &S) -> Result<PathBuf, PathError>
Returns a new path created from the provided source.
A path consists of at list of components separated by :: delimiter. A path must contain
at least one component.
§Errors
Returns an error if:
- The path is empty.
- Any component of the path is empty.
- Any component is not a valid identifier (quoted or unquoted) in Miden Assembly syntax,
i.e. starts with an ASCII alphabetic character, contains only printable ASCII characters,
except for
::, which must only be used as a path separator.
Sourcepub fn into_boxed_path(self) -> Box<Path>
pub fn into_boxed_path(self) -> Box<Path>
Convert this mutable PathBuf into an owned, read-only alloc::boxed::Box<Path>
Source§impl PathBuf
Mutation
impl PathBuf
Mutation
Sourcepub fn set_parent<P>(&mut self, parent: &P)
pub fn set_parent<P>(&mut self, parent: &P)
Overrides the parent prefix of this path.
The parent prefix is the part of the path consisting of all components but the last one.
If there is only a single component in self, this function is equivalent to appending
self to parent.
Sourcepub fn push<P>(&mut self, path: &P)
pub fn push<P>(&mut self, path: &P)
Extends self with path
If path is absolute, it replaces the current path.
This function ensures that the joined path correctly delimits each path component, and that each component is in canonical form.
Sourcepub fn push_component<S>(&mut self, component: &S)
pub fn push_component<S>(&mut self, component: &S)
Extends self with component.
Unlike Self::push, which appends another Path to the buffer - this method appends the
given string as a single path component, ensuring that the content is quoted properly if
needed.
If :: is pushed, it is treated as a literal root component (i.e. it makes the path
absolute). On a non-empty PathBuf, this has the effect of clearing the path, similar to
what happens if you call PathBuf::push with an absolute path.
Pushing components using this method guarantees they are in canonical form.
Sourcepub fn pop(&mut self) -> bool
pub fn pop(&mut self) -> bool
Truncates self to Path::parent.
Returns false if self.parent() is None, otherwise true.
Methods from Deref<Target = Path>§
pub const MAX_COMPONENT_LENGTH: usize
pub const EMPTY: &'static Path
pub const KERNEL_PATH: &'static str = "$kernel"
pub const ABSOLUTE_KERNEL_PATH: &'static str = "::$kernel"
pub const KERNEL: &'static Path
pub const EXEC_PATH: &'static str = "$exec"
pub const ABSOLUTE_EXEC_PATH: &'static str = "::$exec"
pub const EXEC: &'static Path
pub fn as_str(&self) -> &str
Sourcepub fn to_path_buf(&self) -> PathBuf
pub fn to_path_buf(&self) -> PathBuf
Sourcepub fn char_len(&self) -> usize
pub fn char_len(&self) -> usize
Return the size of the path in chars when displayed as a string
Sourcepub fn byte_len(&self) -> usize
pub fn byte_len(&self) -> usize
Return the size of the path in bytes when displayed as a string
Sourcepub fn is_absolute(&self) -> bool
pub fn is_absolute(&self) -> bool
Returns true if this path is an absolute path
Sourcepub fn to_absolute(&self) -> Cow<'_, Path>
pub fn to_absolute(&self) -> Cow<'_, Path>
Make this path absolute, if not already
NOTE: This does not resolve the path, it simply ensures the path has the root prefix
Sourcepub fn to_relative(&self) -> &Path
pub fn to_relative(&self) -> &Path
Strip the root prefix from this path, if it has one.
Sourcepub fn components(&self) -> Iter<'_> ⓘ
pub fn components(&self) -> Iter<'_> ⓘ
Returns an iterator over all components of the path.
Sourcepub fn first(&self) -> Option<&str>
pub fn first(&self) -> Option<&str>
Get the first non-root component of this path as a str
Returns None if the path is empty, or consists only of the root prefix.
Sourcepub fn last(&self) -> Option<&str>
pub fn last(&self) -> Option<&str>
Get the first non-root component of this path as a str
Returns None if the path is empty, or consists only of the root prefix.
Sourcepub fn split_first(&self) -> Option<(&str, &Path)>
pub fn split_first(&self) -> Option<(&str, &Path)>
Splits this path on the first non-root component, returning it and a new Path of the remaining components.
Returns None if there are no components to split
Sourcepub fn split_last(&self) -> Option<(&str, &Path)>
pub fn split_last(&self) -> Option<(&str, &Path)>
Splits this path on the last component, returning it and a new Path of the remaining components.
Returns None if there are no components to split
Sourcepub fn is_kernel_path(&self) -> bool
pub fn is_kernel_path(&self) -> bool
Returns true if this path is for the root kernel module.
Sourcepub fn is_in_kernel(&self) -> bool
pub fn is_in_kernel(&self) -> bool
Returns true if this path is for the root kernel module or an item in it
Sourcepub fn is_exec_path(&self) -> bool
pub fn is_exec_path(&self) -> bool
Returns true if this path is for an executable module.
Sourcepub fn is_in_exec(&self) -> bool
pub fn is_in_exec(&self) -> bool
Returns true if this path is for the executable module or an item in it
Sourcepub fn starts_with<Prefix>(&self, prefix: &Prefix) -> bool
pub fn starts_with<Prefix>(&self, prefix: &Prefix) -> bool
Returns true if the current path, sans root component, starts with prefix
The matching semantics of Prefix depend on the implementation of StartsWith<Prefix>,
in particular, if Prefix is str, then the prefix is matched against the first non-root
component of self, regardless of whether the string contains path delimiters (i.e. ::).
See the StartsWith trait for more details.
Sourcepub fn starts_with_exactly<Prefix>(&self, prefix: &Prefix) -> bool
pub fn starts_with_exactly<Prefix>(&self, prefix: &Prefix) -> bool
Returns true if the current path, including root component, starts with prefix
The matching semantics of Prefix depend on the implementation of StartsWith<Prefix>,
in particular, if Prefix is str, then the prefix is matched against the first component
of self, regardless of whether the string contains path delimiters (i.e. ::).
See the StartsWith trait for more details.
Sourcepub fn strip_prefix<'a>(&'a self, prefix: &Path) -> Option<&'a Path>
pub fn strip_prefix<'a>(&'a self, prefix: &Path) -> Option<&'a Path>
Strips prefix from self, or returns None if self does not start with prefix.
NOTE: Prefixes must be exact, i.e. if you call path.strip_prefix(prefix) and path is
relative but prefix is absolute, then this will return None. The same is true if path
is absolute and prefix is relative.
Sourcepub fn join<P>(&self, other: &P) -> PathBuf
pub fn join<P>(&self, other: &P) -> PathBuf
Create an owned PathBuf with path adjoined to self.
If path is absolute, it replaces the current path.
The semantics of how other is joined to self in the resulting path depends on the
implementation of Join used. The implementation for Path and PathBuf joins all
components of other to self; while the implementation for [prim@str], string-like values, and identifiers/symbols joins just a single component. You must be careful to ensure that if you are passing a string here, that you specifically want to join it as a single component, or the resulting path may be different than you expect. It is recommended that you use Path::new(&string)` if you want to be explicit about treating a string-like value
as a multi-component path.
Sourcepub fn canonicalize(&self) -> Result<PathBuf, PathError>
pub fn canonicalize(&self) -> Result<PathBuf, PathError>
Canonicalize this path by ensuring that all components are in canonical form.
Canonical form dictates that:
- A component is quoted only if it requires quoting, and unquoted otherwise
- Is made absolute if relative and the first component is $kernel or $exec
Returns Err if the path is invalid
Trait Implementations§
Source§impl<'a> AddAssign<&'a Ident> for PathBuf
impl<'a> AddAssign<&'a Ident> for PathBuf
Source§fn add_assign(&mut self, rhs: &'a Ident)
fn add_assign(&mut self, rhs: &'a Ident)
+= operation. Read moreSource§impl<'a> AddAssign<&'a Path> for PathBuf
impl<'a> AddAssign<&'a Path> for PathBuf
Source§fn add_assign(&mut self, rhs: &'a Path)
fn add_assign(&mut self, rhs: &'a Path)
+= operation. Read moreSource§impl<'a> AddAssign<&'a ProcedureName> for PathBuf
impl<'a> AddAssign<&'a ProcedureName> for PathBuf
Source§fn add_assign(&mut self, rhs: &'a ProcedureName)
fn add_assign(&mut self, rhs: &'a ProcedureName)
+= operation. Read moreSource§impl<'a> AddAssign<&'a str> for PathBuf
impl<'a> AddAssign<&'a str> for PathBuf
Source§fn add_assign(&mut self, rhs: &'a str)
fn add_assign(&mut self, rhs: &'a str)
+= operation. Read moreSource§impl Deserializable for PathBuf
impl Deserializable for PathBuf
Source§fn read_from<R>(source: &mut R) -> Result<PathBuf, DeserializationError>where
R: ByteReader,
fn read_from<R>(source: &mut R) -> Result<PathBuf, DeserializationError>where
R: ByteReader,
source, attempts to deserialize these bytes
into Self, and returns the result. Read moreSource§fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
Source§impl From<PathBuf> for QualifiedProcedureName
impl From<PathBuf> for QualifiedProcedureName
Source§fn from(path: PathBuf) -> QualifiedProcedureName
fn from(path: PathBuf) -> QualifiedProcedureName
Source§impl Join<ProcedureName> for PathBuf
impl Join<ProcedureName> for PathBuf
Source§impl Join<QualifiedProcedureName> for PathBuf
impl Join<QualifiedProcedureName> for PathBuf
Source§impl Ord for PathBuf
impl Ord for PathBuf
Source§impl PartialOrd for PathBuf
impl PartialOrd for PathBuf
Source§impl Serializable for PathBuf
impl Serializable for PathBuf
Source§fn write_into<W>(&self, target: &mut W)where
W: ByteWriter,
fn write_into<W>(&self, target: &mut W)where
W: ByteWriter,
self into bytes and writes these bytes into the target.Source§fn get_size_hint(&self) -> usize
fn get_size_hint(&self) -> usize
impl Eq for PathBuf
impl StructuralPartialEq for PathBuf
Auto Trait Implementations§
impl Freeze for PathBuf
impl RefUnwindSafe for PathBuf
impl Send for PathBuf
impl Sync for PathBuf
impl Unpin for PathBuf
impl UnwindSafe for PathBuf
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Source§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§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 moreSource§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