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) -> Result<SourceId, Error>
pub fn from_url(string: &str) -> Result<SourceId, Error>
Parses a source URL and returns the corresponding ID.
§Example
use cargo_lock::SourceId;
SourceId::from_url("git+https://github.com/alexcrichton/\
libssh2-static-sys#80e71a3021618eb05\
656c58fb7c5ef5f12bc747f");Sourcepub fn for_path(path: &Path) -> Result<SourceId, Error>
pub fn for_path(path: &Path) -> Result<SourceId, Error>
Creates a SourceId from a filesystem path.
path: an absolute path.
Sourcepub fn for_git(url: &Url, reference: GitReference) -> Result<SourceId, Error>
pub fn for_git(url: &Url, reference: GitReference) -> Result<SourceId, Error>
Creates a SourceId from a Git reference.
Sourcepub fn for_registry(url: &Url) -> Result<SourceId, Error>
pub fn for_registry(url: &Url) -> Result<SourceId, Error>
Creates a SourceId from a remote registry URL.
Sourcepub fn for_local_registry(path: &Path) -> Result<SourceId, Error>
pub fn for_local_registry(path: &Path) -> Result<SourceId, Error>
Creates a SourceId from a local registry path.
Sourcepub fn for_directory(path: &Path) -> Result<SourceId, Error>
pub fn for_directory(path: &Path) -> Result<SourceId, Error>
Creates a SourceId from a directory path.
Sourcepub fn kind(&self) -> &SourceKind
pub fn kind(&self) -> &SourceKind
Get the kind of source.
Sourcepub fn display_index(&self) -> String
pub fn display_index(&self) -> String
Human-friendly description of an index
Sourcepub fn display_registry_name(&self) -> String
pub fn display_registry_name(&self) -> String
Human-friendly description of a registry name
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 git_reference(&self) -> Option<&GitReference>
pub fn git_reference(&self) -> Option<&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.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for SourceId
impl<'de> Deserialize<'de> for SourceId
Source§fn deserialize<D>(d: D) -> Result<SourceId, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(d: D) -> Result<SourceId, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl Ord for SourceId
We’ve seen a number of subtle ways that dependency references (in package.dependencies)
can differ from the corresponding package.source field for git dependencies.
This Ord impl (which is used when storing SourceIds in a BTreeMap) tries to
account for these differences and treat them as equal.
impl Ord for SourceId
We’ve seen a number of subtle ways that dependency references (in package.dependencies)
can differ from the corresponding package.source field for git dependencies.
This Ord impl (which is used when storing SourceIds in a BTreeMap) tries to
account for these differences and treat them as equal.
The package.source field for a git dependency includes both the tag, branch or rev
(in a query string) used to fetch the dependency, as well as the full commit hash (in the
fragment), but the package.dependencies entry does not include the full commit hash.
Additionally, when the rev is specified for a dependency using a longer hash, the rev
used in the package.source may be an abbreviated hash.
Source§impl PartialOrd for SourceId
impl PartialOrd for SourceId
Source§impl Serialize for SourceId
impl Serialize for SourceId
Source§fn serialize<S>(
&self,
s: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
s: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
impl Eq for SourceId
Auto Trait Implementations§
impl Freeze for SourceId
impl RefUnwindSafe for SourceId
impl Send for SourceId
impl Sync for SourceId
impl Unpin for SourceId
impl UnwindSafe for SourceId
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.