pub struct SourceId { /* private fields */ }Expand description
Unique identifier for a source of packages.
Implementations§
Source§impl SourceId
impl SourceId
Sourcepub fn from_url(string: &str) -> CargoResult<SourceId>
pub fn from_url(string: &str) -> CargoResult<SourceId>
Parses a source URL and returns the corresponding ID.
§Example
use cargo::core::SourceId;
SourceId::from_url("git+https://github.com/alexcrichton/\
libssh2-static-sys#80e71a3021618eb05\
656c58fb7c5ef5f12bc747f");Sourcepub fn into_url(&self) -> SourceIdIntoUrl<'_>
pub fn into_url(&self) -> SourceIdIntoUrl<'_>
A view of the SourceId that can be Displayed as a URL.
Sourcepub fn for_path(path: &Path) -> CargoResult<SourceId>
pub fn for_path(path: &Path) -> CargoResult<SourceId>
Creates a SourceId from a filesystem path.
path: an absolute path.
Sourcepub fn for_git(url: &Url, reference: GitReference) -> CargoResult<SourceId>
pub fn for_git(url: &Url, reference: GitReference) -> CargoResult<SourceId>
Creates a SourceId from a Git reference.
Sourcepub fn for_registry(url: &Url) -> CargoResult<SourceId>
pub fn for_registry(url: &Url) -> CargoResult<SourceId>
Creates a SourceId from a registry URL.
Sourcepub fn for_local_registry(path: &Path) -> CargoResult<SourceId>
pub fn for_local_registry(path: &Path) -> CargoResult<SourceId>
Creates a SourceId from a local registry path.
Sourcepub fn for_directory(path: &Path) -> CargoResult<SourceId>
pub fn for_directory(path: &Path) -> CargoResult<SourceId>
Creates a SourceId from a directory path.
Sourcepub fn crates_io(config: &Config) -> CargoResult<SourceId>
pub fn crates_io(config: &Config) -> CargoResult<SourceId>
Returns the SourceId corresponding to the main repository.
This is the main cargo registry by default, but it can be overridden in
a .cargo/config.
pub fn alt_registry(config: &Config, key: &str) -> CargoResult<SourceId>
Sourcepub fn canonical_url(&self) -> &CanonicalUrl
pub fn canonical_url(&self) -> &CanonicalUrl
Gets the canonical URL of this source, used for internal comparison purposes.
pub fn display_index(self) -> String
pub fn display_registry_name(self) -> String
Sourcepub fn is_registry(self) -> bool
pub fn is_registry(self) -> bool
Returns true if this source is from a registry (either local or not).
Sourcepub fn is_remote_registry(self) -> bool
pub fn is_remote_registry(self) -> bool
Returns true if this source is a “remote” registry.
“remote” may also mean a file URL to a git index, so it is not
necessarily “remote”. This just means it is not local-registry.
Sourcepub fn load<'a>(
self,
config: &'a Config,
yanked_whitelist: &HashSet<PackageId>,
) -> CargoResult<Box<dyn Source + 'a>>
pub fn load<'a>( self, config: &'a Config, yanked_whitelist: &HashSet<PackageId>, ) -> CargoResult<Box<dyn Source + 'a>>
Creates an implementation of Source corresponding to this ID.
Sourcepub fn git_reference(self) -> Option<&'static GitReference>
pub fn git_reference(self) -> Option<&'static GitReference>
Gets the Git reference if this is a git source, otherwise None.
Sourcepub fn with_precise(self, v: Option<String>) -> SourceId
pub fn with_precise(self, v: Option<String>) -> SourceId
Creates a new SourceId from this source with the given precise.
Sourcepub fn is_default_registry(self) -> bool
pub fn is_default_registry(self) -> bool
Returns true if the remote registry is the standard https://crates.io.
Sourcepub fn stable_hash<S: Hasher>(self, workspace: &Path, into: &mut S)
pub fn stable_hash<S: Hasher>(self, workspace: &Path, into: &mut S)
Hashes self.
For paths, remove the workspace prefix so the same source will give the same hash in different locations.