Skip to main content

Registry

Trait Registry 

Source
pub trait Registry {
    // Required methods
    async fn query(
        &self,
        dep: &Dependency,
        kind: QueryKind,
        f: &mut dyn FnMut(IndexSummary),
    ) -> CargoResult<()>;
    fn describe_source(&self, source: SourceId) -> String;
    fn is_replaced(&self, source: SourceId) -> bool;

    // Provided method
    async fn query_vec(
        &self,
        dep: &Dependency,
        kind: QueryKind,
    ) -> CargoResult<Vec<IndexSummary>> { ... }
}
Expand description

An abstraction provides a set of methods for querying source information about a group of packages, without leaking too much implementation details of the actual registry.

As of 2024-04, only PackageRegistry and MyRegistry in resolver-tests are found implementing this.

See also the Source trait, as many of the methods here mirror and abstract over its functionalities.

Required Methods§

Source

async fn query( &self, dep: &Dependency, kind: QueryKind, f: &mut dyn FnMut(IndexSummary), ) -> CargoResult<()>

Attempt to find the packages that match a dependency request.

Source

fn describe_source(&self, source: SourceId) -> String

Gets the description of a source, to provide useful messages.

Source

fn is_replaced(&self, source: SourceId) -> bool

Checks if a source is replaced with some other source.

Provided Methods§

Source

async fn query_vec( &self, dep: &Dependency, kind: QueryKind, ) -> CargoResult<Vec<IndexSummary>>

Gathers the result from Registry::query as a list of IndexSummary items when they become available.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'gctx> Registry for PackageRegistry<'gctx>