Struct cargo::core::PackageIdSpec [−][src]
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
impl PackageIdSpec
[src]
pub fn parse(spec: &str) -> CargoResult<PackageIdSpec>
[src]
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#1.2.3", "https://crates.io/foo#bar:1.2.3", "crates.io/foo", "crates.io/foo#1.2.3", "crates.io/foo#bar", "crates.io/foo#bar:1.2.3", "foo", "foo:1.2.3", ]; for spec in specs { assert!(PackageIdSpec::parse(spec).is_ok()); }
pub fn query_str<I>(spec: &str, i: I) -> CargoResult<PackageId> where
I: IntoIterator<Item = PackageId>,
[src]
I: IntoIterator<Item = PackageId>,
Roughly equivalent to PackageIdSpec::parse(spec)?.query(i)
pub fn from_package_id(package_id: PackageId) -> PackageIdSpec
[src]
Convert a PackageId
to a PackageIdSpec
, which will have both the Version
and Url
fields filled in.
pub fn name(&self) -> InternedString
[src]
pub fn version(&self) -> Option<&Version>
[src]
pub fn url(&self) -> Option<&Url>
[src]
pub fn set_url(&mut self, url: Url)
[src]
pub fn matches(&self, package_id: PackageId) -> bool
[src]
Checks whether the given PackageId
matches the PackageIdSpec
.
pub fn query<I>(&self, i: I) -> CargoResult<PackageId> where
I: IntoIterator<Item = PackageId>,
[src]
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
impl Clone for PackageIdSpec
[src]
fn clone(&self) -> PackageIdSpec
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for PackageIdSpec
[src]
impl<'de> Deserialize<'de> for PackageIdSpec
[src]
fn deserialize<D>(d: D) -> Result<PackageIdSpec, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
impl Display for PackageIdSpec
[src]
impl Eq for PackageIdSpec
[src]
impl Hash for PackageIdSpec
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for PackageIdSpec
[src]
fn cmp(&self, other: &PackageIdSpec) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl PartialEq<PackageIdSpec> for PackageIdSpec
[src]
fn eq(&self, other: &PackageIdSpec) -> bool
[src]
fn ne(&self, other: &PackageIdSpec) -> bool
[src]
impl PartialOrd<PackageIdSpec> for PackageIdSpec
[src]
fn partial_cmp(&self, other: &PackageIdSpec) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl Serialize for PackageIdSpec
[src]
impl StructuralEq for PackageIdSpec
[src]
impl StructuralPartialEq for PackageIdSpec
[src]
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
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
[src]
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
[src]
V: MultiLane<T>,