pub struct SourceId { /* private fields */ }
Expand description
Unique identifier for a source of packages.
Implementations§
Source§impl SourceId
impl SourceId
Sourcepub fn normalize_git_source_for_dependency(&self) -> Self
pub fn normalize_git_source_for_dependency(&self) -> Self
SourceIds with git references used in package.source fields are subtly
different than those in parenthesized source URLs that appear in disambiguated
entries of package.dependencies: the former have the form ?rev=ABBREV#FULLHASH
whereas the latter have the form ?rev=FULLHASH. This method changes the former
into the latter, and is used in impl From<&Package> for Dependency
.
Sourcepub fn from_url(string: &str) -> Result<Self>
pub fn from_url(string: &str) -> Result<Self>
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<Self>
Available on Unix or Windows only.
pub fn for_path(path: &Path) -> Result<Self>
Creates a SourceId
from a filesystem path.
path
: an absolute path.
Sourcepub fn for_git(url: &Url, reference: GitReference) -> Result<Self>
pub fn for_git(url: &Url, reference: GitReference) -> Result<Self>
Creates a SourceId
from a Git reference.
Sourcepub fn for_registry(url: &Url) -> Result<Self>
pub fn for_registry(url: &Url) -> Result<Self>
Creates a SourceId from a remote registry URL.
Sourcepub fn for_local_registry(path: &Path) -> Result<Self>
Available on Unix or Windows only.
pub fn for_local_registry(path: &Path) -> Result<Self>
Creates a SourceId from a local registry path.
Sourcepub fn for_directory(path: &Path) -> Result<Self>
Available on Unix or Windows only.
pub fn for_directory(path: &Path) -> Result<Self>
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>) -> Self
pub fn with_precise(&self, v: Option<String>) -> Self
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: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
Source§impl Ord for SourceId
impl Ord for SourceId
Source§impl PartialOrd for SourceId
impl PartialOrd for SourceId
impl Eq for SourceId
impl StructuralPartialEq 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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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§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.