Struct check_latest::Versions[][src]

pub struct Versions { /* fields omitted */ }
Expand description

A collection of Versions.

Implementations

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]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

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

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
    __D: Deserializer<'de>, 
[src]

Deserialize this value from the given Serde deserializer. Read more

Auto Trait Implementations

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> Instrument for T[src]

fn instrument(self, span: Span) -> Instrumented<Self>[src]

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

fn in_current_span(self) -> Instrumented<Self>[src]

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

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

pub fn into(self) -> U[src]

Performs the conversion.

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

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