pub struct SourceId { /* private fields */ }
Expand description
Unique identifier for a source of packages.
Implementations
sourceimpl 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 as_url(&self) -> SourceIdAsUrl<'_>
pub fn as_url(&self) -> SourceIdAsUrl<'_>
A view of the SourceId
that can be Display
ed 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 local_path(self) -> Option<PathBuf>
pub fn local_path(self) -> Option<PathBuf>
Returns the local path if this is a path dependency.
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.
pub fn full_eq(self, other: SourceId) -> bool
pub fn full_hash<S: Hasher>(self, into: &mut S)
Trait Implementations
sourceimpl<'de> Deserialize<'de> for SourceId
impl<'de> Deserialize<'de> for SourceId
sourcefn deserialize<D>(d: D) -> Result<SourceId, D::Error> where
D: Deserializer<'de>,
fn deserialize<D>(d: D) -> Result<SourceId, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Ord for SourceId
impl Ord for SourceId
sourceimpl PartialOrd<SourceId> for SourceId
impl PartialOrd<SourceId> for SourceId
sourcefn partial_cmp(&self, other: &SourceId) -> Option<Ordering>
fn partial_cmp(&self, other: &SourceId) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Copy for SourceId
impl Eq for SourceId
impl StructuralEq for SourceId
Auto Trait Implementations
impl RefUnwindSafe for SourceId
impl Send for SourceId
impl Sync for SourceId
impl Unpin for SourceId
impl UnwindSafe for SourceId
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more