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 to_url(&self) -> SourceIdToUrl<'_>
pub fn to_url(&self) -> SourceIdToUrl<'_>
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>
Create a SourceId from a filesystem path.
Pass absolute path
Sourcepub fn for_git(url: &Url, reference: GitReference) -> CargoResult<SourceId>
pub fn for_git(url: &Url, reference: GitReference) -> CargoResult<SourceId>
Crate a SourceId from a git reference
Sourcepub fn for_registry(url: &Url) -> CargoResult<SourceId>
pub fn for_registry(url: &Url) -> CargoResult<SourceId>
Create a SourceId from a registry url
Sourcepub fn for_local_registry(path: &Path) -> CargoResult<SourceId>
pub fn for_local_registry(path: &Path) -> CargoResult<SourceId>
Create a SourceId from a local registry path
Sourcepub fn for_directory(path: &Path) -> CargoResult<SourceId>
pub fn for_directory(path: &Path) -> CargoResult<SourceId>
Create 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>
pub fn display_registry(self) -> String
Sourcepub fn is_registry(self) -> bool
pub fn is_registry(self) -> bool
Is this source from a registry (either local or not)
Sourcepub fn is_alt_registry(self) -> bool
pub fn is_alt_registry(self) -> bool
Is this source from an alternative registry DEPRECATED: This is not correct if the registry name is not known (for example when loaded from an index).
Sourcepub fn load<'a>(self, config: &'a Config) -> CargoResult<Box<dyn Source + 'a>>
pub fn load<'a>(self, config: &'a Config) -> 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>
Get 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
Create a new SourceId from this source with the given precise
Sourcepub fn is_default_registry(self) -> bool
pub fn is_default_registry(self) -> bool
Whether 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)
Hash self
For paths, remove the workspace prefix so the same source will give the same hash in different locations.