Struct cargo::core::PackageIdSpec
source · [−]pub struct PackageIdSpec { /* private fields */ }
Expand description
Some or all of the data required to identify a package:
- the package name (a
String
, required) - the package version (a
Version
, optional) - the package source (a
Url
, optional)
If any of the optional fields are omitted, then the package ID may be ambiguous, there may be more than one package/version/url combo that will match. However, often just the name is sufficient to uniquely define a package ID.
Implementations
sourceimpl PackageIdSpec
impl PackageIdSpec
sourcepub fn parse(spec: &str) -> CargoResult<PackageIdSpec>
pub fn parse(spec: &str) -> CargoResult<PackageIdSpec>
Parses a spec string and returns a PackageIdSpec
if the string was valid.
Examples
Some examples of valid strings
use cargo::core::PackageIdSpec;
let specs = vec![
"https://crates.io/foo",
"https://crates.io/foo#1.2.3",
"https://crates.io/foo#bar:1.2.3",
"https://crates.io/foo#bar@1.2.3",
"foo",
"foo:1.2.3",
"foo@1.2.3",
];
for spec in specs {
assert!(PackageIdSpec::parse(spec).is_ok());
}
sourcepub fn query_str<I>(spec: &str, i: I) -> CargoResult<PackageId> where
I: IntoIterator<Item = PackageId>,
pub fn query_str<I>(spec: &str, i: I) -> CargoResult<PackageId> where
I: IntoIterator<Item = PackageId>,
Roughly equivalent to PackageIdSpec::parse(spec)?.query(i)
sourcepub fn from_package_id(package_id: PackageId) -> PackageIdSpec
pub fn from_package_id(package_id: PackageId) -> PackageIdSpec
Convert a PackageId
to a PackageIdSpec
, which will have both the Version
and Url
fields filled in.
pub fn name(&self) -> InternedString
pub fn version(&self) -> Option<&Version>
pub fn url(&self) -> Option<&Url>
pub fn set_url(&mut self, url: Url)
sourcepub fn matches(&self, package_id: PackageId) -> bool
pub fn matches(&self, package_id: PackageId) -> bool
Checks whether the given PackageId
matches the PackageIdSpec
.
sourcepub fn query<I>(&self, i: I) -> CargoResult<PackageId> where
I: IntoIterator<Item = PackageId>,
pub fn query<I>(&self, i: I) -> CargoResult<PackageId> where
I: IntoIterator<Item = PackageId>,
Checks a list of PackageId
s to find 1 that matches this PackageIdSpec
. If 0, 2, or
more are found, then this returns an error.
Trait Implementations
sourceimpl Clone for PackageIdSpec
impl Clone for PackageIdSpec
sourcefn clone(&self) -> PackageIdSpec
fn clone(&self) -> PackageIdSpec
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for PackageIdSpec
impl Debug for PackageIdSpec
sourceimpl<'de> Deserialize<'de> for PackageIdSpec
impl<'de> Deserialize<'de> for PackageIdSpec
sourcefn deserialize<D>(d: D) -> Result<PackageIdSpec, D::Error> where
D: Deserializer<'de>,
fn deserialize<D>(d: D) -> Result<PackageIdSpec, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Display for PackageIdSpec
impl Display for PackageIdSpec
sourceimpl Hash for PackageIdSpec
impl Hash for PackageIdSpec
sourceimpl Ord for PackageIdSpec
impl Ord for PackageIdSpec
sourceimpl PartialEq<PackageIdSpec> for PackageIdSpec
impl PartialEq<PackageIdSpec> for PackageIdSpec
sourcefn eq(&self, other: &PackageIdSpec) -> bool
fn eq(&self, other: &PackageIdSpec) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &PackageIdSpec) -> bool
fn ne(&self, other: &PackageIdSpec) -> bool
This method tests for !=
.
sourceimpl PartialOrd<PackageIdSpec> for PackageIdSpec
impl PartialOrd<PackageIdSpec> for PackageIdSpec
sourcefn partial_cmp(&self, other: &PackageIdSpec) -> Option<Ordering>
fn partial_cmp(&self, other: &PackageIdSpec) -> 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
sourceimpl Serialize for PackageIdSpec
impl Serialize for PackageIdSpec
impl Eq for PackageIdSpec
impl StructuralEq for PackageIdSpec
impl StructuralPartialEq for PackageIdSpec
Auto Trait Implementations
impl RefUnwindSafe for PackageIdSpec
impl Send for PackageIdSpec
impl Sync for PackageIdSpec
impl Unpin for PackageIdSpec
impl UnwindSafe for PackageIdSpec
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
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.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more