pub struct PackageIndex { /* private fields */ }Expand description
PackageIndex is used as an in-memory database of package information needed for dependency resolution for Miden projects. It records and can provide information about:
- All packages for which there is at least one version available
- All versions of a package that are available
- The dependencies for each version of a package, and their version requirements.
Additionally, PackageIndex implements version selection and dependency resolution for packages in the index. Since this functionality is central to any tooling around Miden projects, we implement it here, rather than push the responsibility onto downstream crates.
This structure does not provide any of the following:
- Package metadata beyond version and dependency requirements
- MAST of indexed packages
- A guarantee that indexed packages actually exist or that their sources/MAST can be obtained
It is up to downstream consumers of the index to construct it and populate it with packages
known to them, such that packages selected by PackageResolver::resolve can be resolved to
relevant artifacts, e.g. an assembled package, Miden project sources, etc.
Implementations§
Source§impl PackageIndex
Construction
impl PackageIndex
Construction
Sourcepub fn register(&mut self, package: &Package)
pub fn register(&mut self, package: &Package)
Register package in the index.
This is essentially a convenience wrapper around PackageIndex::insert for the common
case of populating the index with package information loaded from a Miden project.
Source§impl PackageIndex
Queries
impl PackageIndex
Queries
Sourcepub fn is_available<Q>(&self, name: &Q) -> bool
pub fn is_available<Q>(&self, name: &Q) -> bool
Returns true if package name has any available versions in the index.
Sourcepub fn is_version_available<Q>(&self, name: &Q, version: &Version) -> bool
pub fn is_version_available<Q>(&self, name: &Q, version: &Version) -> bool
Returns true if package name with version is available in the index.
Sourcepub fn find<Q>(
&self,
name: &Q,
requirement: &VersionRequirement,
) -> Option<&BTreeMap<PackageId, VersionSet>>
pub fn find<Q>( &self, name: &Q, requirement: &VersionRequirement, ) -> Option<&BTreeMap<PackageId, VersionSet>>
Search for a version of package name that matches requirement, and return its
dependencies.
The version selected by this method will be the latest one which satisfies requirement.
Sourcepub fn available_versions<Q>(
&self,
package: &Q,
) -> impl Iterator<Item = &Version>
pub fn available_versions<Q>( &self, package: &Q, ) -> impl Iterator<Item = &Version>
Get an iterator over all versions of package available in the index, in descending order.
NOTE: Descending order here is determined by the Ord implementation of Version, which
orders versions by their semantic versioning scheme, and disambiguates using package digests
when known.
Sourcepub fn list_versions<'a, Q>(
&'a self,
package: &'a Q,
requirement: &'a VersionRequirement,
) -> impl Iterator<Item = &'a Version> + 'a
pub fn list_versions<'a, Q>( &'a self, package: &'a Q, requirement: &'a VersionRequirement, ) -> impl Iterator<Item = &'a Version> + 'a
Get an iterator over all versions of package that satisfy `requirement.
Trait Implementations§
Source§impl Default for PackageIndex
impl Default for PackageIndex
Source§fn default() -> PackageIndex
fn default() -> PackageIndex
Source§impl<'a, V, D> FromIterator<(&'a str, V)> for PackageIndex
impl<'a, V, D> FromIterator<(&'a str, V)> for PackageIndex
Auto Trait Implementations§
impl Freeze for PackageIndex
impl RefUnwindSafe for PackageIndex
impl Send for PackageIndex
impl Sync for PackageIndex
impl Unpin for PackageIndex
impl UnsafeUnpin for PackageIndex
impl UnwindSafe for PackageIndex
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
§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