[][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.

Methods

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![
    "http://crates.io/foo#1.2.3",
    "http://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) -> &str[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 PartialOrd<PackageIdSpec> for PackageIdSpec[src]

impl PartialEq<PackageIdSpec> for PackageIdSpec[src]

impl Clone for PackageIdSpec[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Ord for PackageIdSpec[src]

fn max(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the minimum of two values. Read more

impl Eq for PackageIdSpec[src]

impl Display for PackageIdSpec[src]

impl Debug for PackageIdSpec[src]

impl Hash for PackageIdSpec[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl Serialize for PackageIdSpec[src]

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

Auto Trait Implementations

Blanket Implementations

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

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

type Owned = T

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

impl<T> From for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

impl<T, U> TryInto 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<T> Any for T where
    T: 'static + ?Sized
[src]

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

impl<T> Same for T

type Output = T

Should always be Self