pub trait Source {
Show 17 methods
// Required methods
fn source_id(&self) -> SourceId;
fn supports_checksums(&self) -> bool;
fn requires_precise(&self) -> bool;
fn query(
&mut self,
dep: &Dependency,
f: &mut dyn FnMut(Summary),
) -> CargoResult<()>;
fn fuzzy_query(
&mut self,
dep: &Dependency,
f: &mut dyn FnMut(Summary),
) -> CargoResult<()>;
fn update(&mut self) -> CargoResult<()>;
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) -> CargoResult<bool>;
// Provided methods
fn replaced_source_id(&self) -> SourceId { ... }
fn query_vec(&mut self, dep: &Dependency) -> 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§
Sourcefn supports_checksums(&self) -> bool
fn supports_checksums(&self) -> bool
Returns whether or not this source will return summaries with checksums listed.
Sourcefn requires_precise(&self) -> bool
fn requires_precise(&self) -> bool
Returns whether or not this source will return summaries with
the precise field in the source id listed.
Sourcefn query(
&mut self,
dep: &Dependency,
f: &mut dyn FnMut(Summary),
) -> CargoResult<()>
fn query( &mut self, dep: &Dependency, f: &mut dyn FnMut(Summary), ) -> CargoResult<()>
Attempts to find the packages that match a dependency request.
Sourcefn fuzzy_query(
&mut self,
dep: &Dependency,
f: &mut dyn FnMut(Summary),
) -> CargoResult<()>
fn fuzzy_query( &mut self, dep: &Dependency, f: &mut dyn FnMut(Summary), ) -> CargoResult<()>
Attempts to find the packages that are close to a dependency request.
Each source gets to define what close means for it.
Path/Git sources may return all dependencies that are at that URI,
whereas an Index source may return dependencies that have the same canonicalization.
Sourcefn update(&mut self) -> CargoResult<()>
fn update(&mut self) -> CargoResult<()>
Performs any network operations required to get the entire list of all names,
versions and dependencies of packages managed by the Source.
Sourcefn download(&mut self, package: PackageId) -> CargoResult<MaybePackage>
fn download(&mut self, package: PackageId) -> CargoResult<MaybePackage>
Fetches the full package for each name and version specified.
fn finish_download( &mut self, package: PackageId, contents: Vec<u8>, ) -> CargoResult<Package>
Sourcefn fingerprint(&self, pkg: &Package) -> CargoResult<String>
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 “fresheness” 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.
Sourcefn describe(&self) -> String
fn describe(&self) -> String
Describes this source in a human readable fashion, used for display in resolver error messages currently.
Sourcefn add_to_yanked_whitelist(&mut self, pkgs: &[PackageId])
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.
Sourcefn is_yanked(&mut self, _pkg: PackageId) -> CargoResult<bool>
fn is_yanked(&mut self, _pkg: PackageId) -> CargoResult<bool>
Query if a package is yanked. Only registry sources can mark packages as yanked. This ignores the yanked whitelist.
Provided Methods§
Sourcefn replaced_source_id(&self) -> SourceId
fn replaced_source_id(&self) -> SourceId
Returns the replaced SourceId corresponding to this source.
fn query_vec(&mut self, dep: &Dependency) -> CargoResult<Vec<Summary>>
fn download_now(
self: Box<Self>,
package: PackageId,
config: &Config,
) -> CargoResult<Package>where
Self: Sized,
Sourcefn verify(&self, _pkg: PackageId) -> CargoResult<()>
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.
Sourcefn is_replaced(&self) -> bool
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
impl<'a, T: Source + ?Sized + 'a> Source for &'a mut T
fn source_id(&self) -> SourceId
fn replaced_source_id(&self) -> SourceId
fn supports_checksums(&self) -> bool
fn requires_precise(&self) -> bool
fn query( &mut self, dep: &Dependency, f: &mut dyn FnMut(Summary), ) -> CargoResult<()>
fn fuzzy_query( &mut self, dep: &Dependency, f: &mut dyn FnMut(Summary), ) -> CargoResult<()>
fn update(&mut self) -> CargoResult<()>
fn download(&mut self, id: PackageId) -> CargoResult<MaybePackage>
fn finish_download( &mut self, id: PackageId, data: Vec<u8>, ) -> CargoResult<Package>
fn fingerprint(&self, pkg: &Package) -> CargoResult<String>
fn verify(&self, pkg: PackageId) -> CargoResult<()>
fn describe(&self) -> String
fn is_replaced(&self) -> bool
fn add_to_yanked_whitelist(&mut self, pkgs: &[PackageId])
fn is_yanked(&mut self, pkg: PackageId) -> CargoResult<bool>
Source§impl<'a, T: Source + ?Sized + 'a> Source for Box<T>
impl<'a, T: Source + ?Sized + 'a> Source for Box<T>
Source§fn replaced_source_id(&self) -> SourceId
fn replaced_source_id(&self) -> SourceId
Forwards to Source::replaced_source_id.
Source§fn supports_checksums(&self) -> bool
fn supports_checksums(&self) -> bool
Forwards to Source::supports_checksums.
Source§fn requires_precise(&self) -> bool
fn requires_precise(&self) -> bool
Forwards to Source::requires_precise.
Source§fn query(
&mut self,
dep: &Dependency,
f: &mut dyn FnMut(Summary),
) -> CargoResult<()>
fn query( &mut self, dep: &Dependency, f: &mut dyn FnMut(Summary), ) -> CargoResult<()>
Forwards to Source::query.
Source§fn fuzzy_query(
&mut self,
dep: &Dependency,
f: &mut dyn FnMut(Summary),
) -> CargoResult<()>
fn fuzzy_query( &mut self, dep: &Dependency, f: &mut dyn FnMut(Summary), ) -> CargoResult<()>
Forwards to Source::query.
Source§fn update(&mut self) -> CargoResult<()>
fn update(&mut self) -> CargoResult<()>
Forwards to Source::update.
Source§fn download(&mut self, id: PackageId) -> CargoResult<MaybePackage>
fn download(&mut self, id: PackageId) -> CargoResult<MaybePackage>
Forwards to Source::download.
Source§fn fingerprint(&self, pkg: &Package) -> CargoResult<String>
fn fingerprint(&self, pkg: &Package) -> CargoResult<String>
Forwards to Source::fingerprint.