[][src]Struct cargo::core::PackageIdSpec

pub struct PackageIdSpec { /* fields omitted */ }

Some or all of the data required to identify a package:

  1. the package name (a String, required)
  2. the package version (a Version, optional)
  3. 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]

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]

Checks a list of PackageIds 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]

impl Debug for PackageIdSpec[src]

impl<'de> Deserialize<'de> for PackageIdSpec[src]

impl Display for PackageIdSpec[src]

impl Eq for PackageIdSpec[src]

impl Hash for PackageIdSpec[src]

impl Ord for PackageIdSpec[src]

impl PartialEq<PackageIdSpec> for PackageIdSpec[src]

impl PartialOrd<PackageIdSpec> for PackageIdSpec[src]

impl Serialize for PackageIdSpec[src]

impl StructuralEq for PackageIdSpec[src]

impl StructuralPartialEq for PackageIdSpec[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,