pub struct LibraryPath { /* private fields */ }
Expand description
Path to a module or a procedure.
Implementations§
Source§impl LibraryPath
impl LibraryPath
Sourcepub fn new(source: impl AsRef<str>) -> Result<LibraryPath, PathError>
pub fn new(source: impl AsRef<str>) -> Result<LibraryPath, 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.
- The path prefix represents an invalid namespace, see LibraryNamespace for details.
- 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 new_from_components<I>(
ns: LibraryNamespace,
components: I,
) -> LibraryPathwhere
I: IntoIterator<Item = Ident>,
pub fn new_from_components<I>(
ns: LibraryNamespace,
components: I,
) -> LibraryPathwhere
I: IntoIterator<Item = Ident>,
Create a LibraryPath from pre-validated components
Source§impl LibraryPath
Path metadata
impl LibraryPath
Path metadata
Sourcepub fn byte_len(&self) -> usize
pub fn byte_len(&self) -> usize
Return the size in bytes of this path when displayed as a string
Sourcepub fn namespace(&self) -> &LibraryNamespace
pub fn namespace(&self) -> &LibraryNamespace
Return the namespace component of this path
Sourcepub fn last_component(&self) -> LibraryPathComponent<'_>
pub fn last_component(&self) -> LibraryPathComponent<'_>
Returns the last component of the path.
Sourcepub fn num_components(&self) -> usize
pub fn num_components(&self) -> usize
Returns the number of components in the path.
This is guaranteed to return at least 1.
Sourcepub fn components(&self) -> impl Iterator<Item = LibraryPathComponent<'_>>
pub fn components(&self) -> impl Iterator<Item = LibraryPathComponent<'_>>
Returns an iterator over all components of the path.
Sourcepub fn is_kernel_path(&self) -> bool
pub fn is_kernel_path(&self) -> bool
Returns true if this path is for a kernel module.
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_anon_path(&self) -> bool
pub fn is_anon_path(&self) -> bool
Returns true if this path is for an anonymous module.
Sourcepub fn starts_with(&self, other: &LibraryPath) -> bool
pub fn starts_with(&self, other: &LibraryPath) -> bool
Returns true if self
starts with other
Source§impl LibraryPath
Mutation
impl LibraryPath
Mutation
Sourcepub fn set_namespace(&mut self, ns: LibraryNamespace)
pub fn set_namespace(&mut self, ns: LibraryNamespace)
Override the current LibraryNamespace for this path.
Sourcepub fn join(&self, other: &LibraryPath) -> Result<LibraryPath, PathError>
pub fn join(&self, other: &LibraryPath) -> Result<LibraryPath, PathError>
Appends the provided path to this path and returns the result.
§Errors
Returns an error if the join would produce an invalid path. For example, paths with reserved namespaces may not be joined to other paths.
Sourcepub fn push(&mut self, component: impl AsRef<str>) -> Result<(), PathError>
pub fn push(&mut self, component: impl AsRef<str>) -> Result<(), PathError>
Append the given component to this path.
Returns an error if the component is not valid.
Sourcepub fn push_ident(&mut self, component: Ident)
pub fn push_ident(&mut self, component: Ident)
Append an Ident as a component to this path
Sourcepub fn append<S>(&self, component: S) -> Result<LibraryPath, PathError>
pub fn append<S>(&self, component: S) -> Result<LibraryPath, PathError>
Appends the provided component to the end of this path and returns the result.
Returns an error if the input string is not a valid component.
Sourcepub fn append_ident(&self, component: Ident) -> Result<LibraryPath, PathError>
pub fn append_ident(&self, component: Ident) -> Result<LibraryPath, PathError>
Appends the provided component to the end of this path and returns the result.
Returns an error if the input string is not a valid component.
Sourcepub fn prepend<S>(&self, component: S) -> Result<LibraryPath, PathError>
pub fn prepend<S>(&self, component: S) -> Result<LibraryPath, PathError>
Adds the provided component to the front of this path and returns the result.
§Errors
Returns an error if:
- The input string is not a valid LibraryNamespace
- The current namespace is a reserved identifier and therefore not a valid path component
Sourcepub fn strip_last(&self) -> Option<LibraryPath>
pub fn strip_last(&self) -> Option<LibraryPath>
Returns a new path, representing the current one with the last non-namespace component removed.
Sourcepub fn validate<S>(source: S) -> Result<usize, PathError>
pub fn validate<S>(source: S) -> Result<usize, PathError>
Checks if the given input string is a valid LibraryPath, returning the number of components in the path.
See the documentation of LibraryPath::new for details on what constitutes a valid path.
Sourcepub fn append_unchecked<S>(&self, component: S) -> LibraryPath
pub fn append_unchecked<S>(&self, component: S) -> LibraryPath
Returns a new LibraryPath with the given component appended without any validation.
The caller is expected to uphold the validity invariants of LibraryPath.
Trait Implementations§
Source§impl Clone for LibraryPath
impl Clone for LibraryPath
Source§fn clone(&self) -> LibraryPath
fn clone(&self) -> LibraryPath
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for LibraryPath
impl Debug for LibraryPath
Source§impl Default for LibraryPath
impl Default for LibraryPath
Source§fn default() -> LibraryPath
fn default() -> LibraryPath
Source§impl Deserializable for LibraryPath
impl Deserializable for LibraryPath
Source§fn read_from<R>(source: &mut R) -> Result<LibraryPath, DeserializationError>where
R: ByteReader,
fn read_from<R>(source: &mut R) -> Result<LibraryPath, 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 Display for LibraryPath
impl Display for LibraryPath
Source§impl From<LibraryNamespace> for LibraryPath
impl From<LibraryNamespace> for LibraryPath
Source§fn from(ns: LibraryNamespace) -> LibraryPath
fn from(ns: LibraryNamespace) -> LibraryPath
Source§impl FromStr for LibraryPath
impl FromStr for LibraryPath
Source§impl Hash for LibraryPath
impl Hash for LibraryPath
Source§impl Ord for LibraryPath
impl Ord for LibraryPath
Source§fn cmp(&self, other: &LibraryPath) -> Ordering
fn cmp(&self, other: &LibraryPath) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for LibraryPath
impl PartialEq for LibraryPath
Source§impl PartialOrd for LibraryPath
impl PartialOrd for LibraryPath
Source§impl Serializable for LibraryPath
impl Serializable for LibraryPath
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
Source§impl<'a> TryFrom<&'a str> for LibraryPath
impl<'a> TryFrom<&'a str> for LibraryPath
Source§impl TryFrom<String> for LibraryPath
impl TryFrom<String> for LibraryPath
Source§impl<'a> TryFrom<Vec<LibraryPathComponent<'a>>> for LibraryPath
impl<'a> TryFrom<Vec<LibraryPathComponent<'a>>> for LibraryPath
Source§fn try_from(
iter: Vec<LibraryPathComponent<'a>>,
) -> Result<LibraryPath, <LibraryPath as TryFrom<Vec<LibraryPathComponent<'a>>>>::Error>
fn try_from( iter: Vec<LibraryPathComponent<'a>>, ) -> Result<LibraryPath, <LibraryPath as TryFrom<Vec<LibraryPathComponent<'a>>>>::Error>
impl Eq for LibraryPath
impl StructuralPartialEq for LibraryPath
Auto Trait Implementations§
impl Freeze for LibraryPath
impl RefUnwindSafe for LibraryPath
impl Send for LibraryPath
impl Sync for LibraryPath
impl Unpin for LibraryPath
impl UnwindSafe for LibraryPath
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<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.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