[][src]Struct check_latest::Versions

pub struct Versions { /* fields omitted */ }

A collection of Versions.

Methods

impl Versions[src]

pub async fn async_new<'_, '_>(
    crate_name: &'_ str,
    user_agent: &'_ str
) -> Result<Versions>
[src]

  • crate_name: The crate that the version should be checked for.
  • user_agent: without a proper User-Agent, the request to the Crates.io API will result in the response below, which we won't be able to parse into crate versions.

Example Response from Bad User Agent

We require that all requests include a `User-Agent` header.  To allow us to determine the impact your bot has on our service, we ask that your user agent actually identify your bot, and not just report the HTTP client library you're using.  Including contact information will also reduce the chance that we will need to take action against your bot.

Bad:
  User-Agent: <bad user agent that you used>

Better:
  User-Agent: my_crawler

Best:
  User-Agent: my_crawler (my_crawler.com/info)
  User-Agent: my_crawler (help@my_crawler.com)

If you believe you've received this message in error, please email help@crates.io and include the request id {}.

Example

use check_latest::Versions;

if let Ok(versions) = Versions::async_new("my-awesome-crate-bin", "my-awesome-crate-bin/1.0.0").await {
    /* Do your stuff */
}

impl Versions[src]

pub fn new(crate_name: &str, user_agent: &str) -> Result<Versions>[src]

  • crate_name: The crate that the version should be checked for.
  • user_agent: without a proper User-Agent, the request to the Crates.io API will result in the response below, which we won't be able to parse into crate versions.

Example Response from Bad User Agent

We require that all requests include a `User-Agent` header.  To allow us to determine the impact your bot has on our service, we ask that your user agent actually identify your bot, and not just report the HTTP client library you're using.  Including contact information will also reduce the chance that we will need to take action against your bot.

Bad:
  User-Agent: <bad user agent that you used>

Better:
  User-Agent: my_crawler

Best:
  User-Agent: my_crawler (my_crawler.com/info)
  User-Agent: my_crawler (help@my_crawler.com)

If you believe you've received this message in error, please email help@crates.io and include the request id {}.

Example

use check_latest::Versions;

if let Ok(versions) = Versions::new("my-awesome-crate-bin", "my-awesome-crate-bin/1.0.0") {
    /* Do your stuff */
}

impl Versions[src]

pub fn max_version(&self) -> Option<&Version>[src]

Gets any max version.

Example

use check_latest::Versions;

let newest = Versions::new("my-cool-crate", "my-cool-crate/1.0.0")
    .unwrap()
    .max_version();

pub fn max_unyanked_version(&self) -> Option<&Version>[src]

Gets the max version that hasn't been yanked.

Example

use check_latest::Versions;

let newest = Versions::new("my-cool-crate", "my-cool-crate/1.0.0")
    .unwrap()
    .max_unyanked_version();

pub fn max_yanked_version(&self) -> Option<&Version>[src]

Gets max version that has been yanked.

Example

use check_latest::Versions;

let newest = Versions::new("my-cool-crate", "my-cool-crate/1.0.0")
    .unwrap()
    .newest_yanked_version();

pub fn max_minor_version(&self, major: u64) -> Option<&Version>[src]

Gets any max version with the same major version.

For example, if major = 1, then 1.0.0 <= max_minor_version < 2.0.0.

Example

use check_latest::Versions;

let newest = Versions::new("my-cool-crate", "my-cool-crate/1.0.0")
    .unwrap()
    .max_minor_version(1);

pub fn max_unyanked_minor_version(&self, major: u64) -> Option<&Version>[src]

Gets the max version that hasn't been yanked with the same major version.

For example, if major = 1, then 1.0.0 <= max_minor_version < 2.0.0.

Example

use check_latest::Versions;

let newest = Versions::new("my-cool-crate", "my-cool-crate/1.0.0")
    .unwrap()
    .max_unyanked_minor_version(1);

pub fn max_yanked_minor_version(&self, major: u64) -> Option<&Version>[src]

Gets max version that has been yanked with the same major version.

For example, if major = 1, then 1.0.0 <= max_minor_version < 2.0.0.

Example

use check_latest::Versions;

let newest = Versions::new("my-cool-crate", "my-cool-crate/1.0.0")
    .unwrap()
    .max_yanked_minor_version(1);

pub fn max_patch(&self, major: u64, minor: u64) -> Option<&Version>[src]

Gets any max version with the same major and minor version.

For example, if major = 1 and minor = 2, then 1.2.0 <= max_patch < 1.3.0.

Example

use check_latest::Versions;

let newest = Versions::new("my-cool-crate", "my-cool-crate/1.0.0")
    .unwrap()
    .max_patch(1, 2);

pub fn max_unyanked_patch(&self, major: u64, minor: u64) -> Option<&Version>[src]

Gets the max version that hasn't been yanked with the same major and minor version.

For example, if major = 1 and minor = 2, then 1.2.0 <= max_patch < 1.3.0.

Example

use check_latest::Versions;

let newest = Versions::new("my-cool-crate", "my-cool-crate/1.0.0")
    .unwrap()
    .max_unyanked_patch(1, 2);

pub fn max_yanked_patch(&self, major: u64, minor: u64) -> Option<&Version>[src]

Gets max version that has been yanked with the same major and minor version.

For example, if major = 1 and minor = 2, then 1.2.0 <= max_patch < 1.3.0.

Example

use check_latest::Versions;

let newest = Versions::new("my-cool-crate", "my-cool-crate/1.0.0")
    .unwrap()
    .max_yanked_patch(1, 2);

pub fn newest_version(&self) -> Option<&Version>[src]

Gets any newest version.

Example

use check_latest::Versions;

let newest = Versions::new("my-cool-crate", "my-cool-crate/1.0.0")
    .unwrap()
    .newest_version();

pub fn newest_unyanked_version(&self) -> Option<&Version>[src]

Gets the newest version that hasn't been yanked.

Example

use check_latest::Versions;

let newest = Versions::new("my-cool-crate", "my-cool-crate/1.0.0")
    .unwrap()
    .newest_unyanked_version();

pub fn newest_yanked_version(&self) -> Option<&Version>[src]

Gets newest version that has been yanked.

Example

use check_latest::Versions;

let newest = Versions::new("my-cool-crate", "my-cool-crate/1.0.0")
    .unwrap()
    .newest_yanked_version();

pub fn versions(&self) -> &Vec<Version>[src]

Gets the full list of versions that were found.

pub fn versions_mut(&mut self) -> &mut Vec<Version>[src]

Gets a mutable list of versions that were found.

pub fn versions_owned(self) -> Vec<Version>[src]

Takes ownership of self and returns owned versions list.

Trait Implementations

impl Debug for Versions[src]

impl<'de> Deserialize<'de> for Versions[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: Deserialize<'de>, 
[src]

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

impl<T, U> Into<U> for T where
    U: From<T>, 
[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.