Struct PathBuf
pub struct PathBuf { /* private fields */ }Expand description
Path to an item in a library, i.e. module, procedure, constant or type.
Implementations§
§impl PathBuf
Constructors
impl PathBuf
Constructors
pub 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
pub 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.
pub 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>
§impl PathBuf
Mutation
impl PathBuf
Mutation
pub 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.
pub 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.
pub 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.
pub 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
pub fn to_path_buf(&self) -> PathBuf
pub fn to_path_buf(&self) -> PathBuf
pub fn is_absolute(&self) -> bool
pub fn is_absolute(&self) -> bool
Returns true if this path is an absolute path
pub 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
pub fn to_relative(&self) -> &Path
pub fn to_relative(&self) -> &Path
Strip the root prefix from this path, if it has one.
pub fn components(&self) -> Iter<'_> ⓘ
pub fn components(&self) -> Iter<'_> ⓘ
Returns an iterator over all components of the path.
pub 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.
pub 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.
pub 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
pub 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
pub fn is_kernel_path(&self) -> bool
pub fn is_kernel_path(&self) -> bool
Returns true if this path is for the root kernel module.
pub 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
pub fn is_exec_path(&self) -> bool
pub fn is_exec_path(&self) -> bool
Returns true if this path is for an executable module.
pub 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
pub 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.
pub 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.
pub 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.
pub 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.
pub 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§
§impl<'a> AddAssign<&'a Ident> for PathBuf
impl<'a> AddAssign<&'a Ident> for PathBuf
§fn add_assign(&mut self, rhs: &'a Ident)
fn add_assign(&mut self, rhs: &'a Ident)
+= operation. Read more§impl<'a> AddAssign<&'a Path> for PathBuf
impl<'a> AddAssign<&'a Path> for PathBuf
§fn add_assign(&mut self, rhs: &'a Path)
fn add_assign(&mut self, rhs: &'a Path)
+= operation. Read more§impl<'a> AddAssign<&'a ProcedureName> for PathBuf
impl<'a> AddAssign<&'a ProcedureName> for PathBuf
§fn add_assign(&mut self, rhs: &'a ProcedureName)
fn add_assign(&mut self, rhs: &'a ProcedureName)
+= operation. Read more§impl<'a> AddAssign<&'a str> for PathBuf
impl<'a> AddAssign<&'a str> for PathBuf
§fn add_assign(&mut self, rhs: &'a str)
fn add_assign(&mut self, rhs: &'a str)
+= operation. Read more§impl Arbitrary for PathBuf
impl Arbitrary for PathBuf
§type Parameters = ()
type Parameters = ()
arbitrary_with accepts for configuration
of the generated Strategy. Parameters must implement Default.§fn arbitrary_with(
_args: <PathBuf as Arbitrary>::Parameters,
) -> <PathBuf as Arbitrary>::Strategy
fn arbitrary_with( _args: <PathBuf as Arbitrary>::Parameters, ) -> <PathBuf as Arbitrary>::Strategy
§impl Deserializable for PathBuf
impl Deserializable for PathBuf
§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 more§fn min_serialized_size() -> usize
fn min_serialized_size() -> usize
§fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
§fn read_from_bytes_with_budget(
bytes: &[u8],
budget: usize,
) -> Result<Self, DeserializationError>
fn read_from_bytes_with_budget( bytes: &[u8], budget: usize, ) -> Result<Self, DeserializationError>
Self from bytes with a byte budget limit. Read more§impl<'de> Deserialize<'de> for PathBuf
Available on crate feature serde only.
impl<'de> Deserialize<'de> for PathBuf
serde only.§fn deserialize<D>(
deserializer: D,
) -> Result<PathBuf, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<PathBuf, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
§impl From<PathBuf> for QualifiedProcedureName
impl From<PathBuf> for QualifiedProcedureName
§fn from(path: PathBuf) -> QualifiedProcedureName
fn from(path: PathBuf) -> QualifiedProcedureName
§impl Join<ProcedureName> for PathBuf
impl Join<ProcedureName> for PathBuf
§impl Join<QualifiedProcedureName> for PathBuf
impl Join<QualifiedProcedureName> for PathBuf
§impl Ord for PathBuf
impl Ord for PathBuf
§impl PartialOrd for PathBuf
impl PartialOrd for PathBuf
§impl Serializable for PathBuf
impl Serializable for PathBuf
§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.§fn get_size_hint(&self) -> usize
fn get_size_hint(&self) -> usize
§impl Serialize for PathBuf
Available on crate feature serde only.
impl Serialize for PathBuf
serde only.§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
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 UnsafeUnpin 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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§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_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, 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