# Trait cargo::core::source::Source

source ·

    pub trait Source {
    Show 18 methods    // Required methods
        fn source_id(&self) -> SourceId;
        fn supports_checksums(&self) -> bool;
        fn requires_precise(&self) -> bool;
        fn query(
            &mut self,
            dep: &Dependency,
            kind: QueryKind,
            f: &mut dyn FnMut(Summary)
        ) -> Poll<CargoResult<()>>;
        fn invalidate_cache(&mut self);
        fn set_quiet(&mut self, quiet: bool);
        fn download(&mut self, package: PackageId) -> CargoResult<MaybePackage>;
        fn finish_download(
            &mut self,
            package: PackageId,
            contents: Vec<u8>
        ) -> CargoResult<Package>;
        fn fingerprint(&self, pkg: &Package) -> CargoResult<String>;
        fn describe(&self) -> String;
        fn add_to_yanked_whitelist(&mut self, pkgs: &[PackageId]);
        fn is_yanked(&mut self, _pkg: PackageId) -> Poll<CargoResult<bool>>;
        fn block_until_ready(&mut self) -> CargoResult<()>;

        // Provided methods
        fn replaced_source_id(&self) -> SourceId { ... }
        fn query_vec(
            &mut self,
            dep: &Dependency,
            kind: QueryKind
        ) -> Poll<CargoResult<Vec<Summary>>> { ... }
        fn download_now(
            self: Box<Self>,
            package: PackageId,
            config: &Config
        ) -> CargoResult<Package>
           where Self: Sized { ... }
        fn verify(&self, _pkg: PackageId) -> CargoResult<()> { ... }
        fn is_replaced(&self) -> bool { ... }
    }

Expand description

Something that finds and downloads remote packages based on names and versions.

## Required Methods§

source

#### fn source_id(&self) -> SourceId

Returns the `SourceId` corresponding to this source.

source

#### fn supports_checksums(&self) -> bool

Returns whether or not this source will return summaries with checksums listed.

source

#### fn requires_precise(&self) -> bool

Returns whether or not this source will return summaries with the `precise` field in the source id listed.

source

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

Attempts to find the packages that match a dependency request.

source

#### fn invalidate_cache(&mut self)

Ensure that the source is fully up-to-date for the current session on the next query.

source

#### fn set_quiet(&mut self, quiet: bool)

If quiet, the source should not display any progress or status messages.

source

#### fn download(&mut self, package: PackageId) -> CargoResult<MaybePackage>

Fetches the full package for each name and version specified.

source

#### fn finish_download( &mut self, package: PackageId, contents: Vec<u8> ) -> CargoResult<Package>

source

#### fn fingerprint(&self, pkg: &Package) -> CargoResult<String>

Generates a unique string which represents the fingerprint of the current state of the source.

This fingerprint is used to determine the “freshness” of the source later on. It must be guaranteed that the fingerprint of a source is constant if and only if the output product will remain constant.

The `pkg` argument is the package which this fingerprint should only be interested in for when this source may contain multiple packages.

source

#### fn describe(&self) -> String

Describes this source in a human readable fashion, used for display in resolver error messages currently.

source

#### fn add_to_yanked_whitelist(&mut self, pkgs: &[PackageId])

Add a number of crates that should be whitelisted for showing up during queries, even if they are yanked. Currently only applies to registry sources.

source

#### fn is_yanked(&mut self, _pkg: PackageId) -> Poll<CargoResult<bool>>

Query if a package is yanked. Only registry sources can mark packages as yanked. This ignores the yanked whitelist.

source

#### fn block_until_ready(&mut self) -> CargoResult<()>

Block until all outstanding Poll::Pending requests are `Poll::Ready`.

After calling this function, the source should return `Poll::Ready` for any queries that previously returned `Poll::Pending`.

If no queries previously returned `Poll::Pending`, and `invalidate_cache` was not called, this function should be a no-op.

## Provided Methods§

source

#### fn replaced_source_id(&self) -> SourceId

Returns the replaced `SourceId` corresponding to this source.

source

#### fn query_vec( &mut self, dep: &Dependency, kind: QueryKind ) -> Poll<CargoResult<Vec<Summary>>>

source

#### fn download_now( self: Box<Self>, package: PackageId, config: &Config ) -> CargoResult<Package>where Self: Sized,

source

#### fn verify(&self, _pkg: PackageId) -> CargoResult<()>

If this source supports it, verifies the source of the package specified.

Note that the source may also have performed other checksum-based verification during the `download` step, but this is intended to be run just before a crate is compiled so it may perform more expensive checks which may not be cacheable.

source

#### fn is_replaced(&self) -> bool

Returns whether a source is being replaced by another here.

## Implementations on Foreign Types§

source§

### impl<'a, T: Source + ?Sized + 'a> Source for &'a mut T

source§

#### fn source_id(&self) -> SourceId

source§

#### fn replaced_source_id(&self) -> SourceId

source§

#### fn supports_checksums(&self) -> bool

source§

#### fn requires_precise(&self) -> bool

source§

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

source§

#### fn invalidate_cache(&mut self)

source§

#### fn set_quiet(&mut self, quiet: bool)

source§

#### fn download(&mut self, id: PackageId) -> CargoResult<MaybePackage>

source§

#### fn finish_download( &mut self, id: PackageId, data: Vec<u8> ) -> CargoResult<Package>

source§

#### fn fingerprint(&self, pkg: &Package) -> CargoResult<String>

source§

#### fn verify(&self, pkg: PackageId) -> CargoResult<()>

source§

#### fn describe(&self) -> String

source§

#### fn is_replaced(&self) -> bool

source§

#### fn add_to_yanked_whitelist(&mut self, pkgs: &[PackageId])

source§

#### fn is_yanked(&mut self, pkg: PackageId) -> Poll<CargoResult<bool>>

source§

#### fn block_until_ready(&mut self) -> CargoResult<()>

source§

### impl<'a, T: Source + ?Sized + 'a> Source for Box<T>

source§

#### fn source_id(&self) -> SourceId

Forwards to `Source::source_id`.

source§

#### fn replaced_source_id(&self) -> SourceId

Forwards to `Source::replaced_source_id`.

source§

#### fn supports_checksums(&self) -> bool

Forwards to `Source::supports_checksums`.

source§

#### fn requires_precise(&self) -> bool

Forwards to `Source::requires_precise`.

source§

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

Forwards to `Source::query`.

source§

#### fn download(&mut self, id: PackageId) -> CargoResult<MaybePackage>

Forwards to `Source::download`.

source§

#### fn fingerprint(&self, pkg: &Package) -> CargoResult<String>

Forwards to `Source::fingerprint`.

source§

#### fn verify(&self, pkg: PackageId) -> CargoResult<()>

Forwards to `Source::verify`.

source§

#### fn invalidate_cache(&mut self)

source§

#### fn set_quiet(&mut self, quiet: bool)

source§

#### fn finish_download( &mut self, id: PackageId, data: Vec<u8> ) -> CargoResult<Package>

source§

#### fn describe(&self) -> String

source§

#### fn is_replaced(&self) -> bool

source§

#### fn add_to_yanked_whitelist(&mut self, pkgs: &[PackageId])

source§

#### fn is_yanked(&mut self, pkg: PackageId) -> Poll<CargoResult<bool>>

source§

#### fn block_until_ready(&mut self) -> CargoResult<()>

## Implementors§

source§

### impl<'cfg> Source for DirectorySource<'cfg>

source§

### impl<'cfg> Source for GitSource<'cfg>

source§

### impl<'cfg> Source for PathSource<'cfg>

source§

### impl<'cfg> Source for RegistrySource<'cfg>

source§

### impl<'cfg> Source for ReplacedSource<'cfg>