Versions

Struct Versions 

Source
pub struct Versions { /* private fields */ }
Expand description

A collection of Versions.

Implementations§

Source§

impl Versions

Source

pub async fn async_new(crate_name: &str, user_agent: &str) -> Result<Versions>

  • 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 */
}
Source§

impl Versions

Source

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

  • 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 */
}
Source§

impl Versions

Source

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

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();
Source

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

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();
Source

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

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();
Source

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

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);
Source

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

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);
Source

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

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);
Source

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

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);
Source

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

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);
Source

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

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);
Source

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

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();
Source

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

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();
Source

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

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();
Source

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

Gets the full list of versions that were found.

Source

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

Gets a mutable list of versions that were found.

Source

pub fn versions_owned(self) -> Vec<Version>

Takes ownership of self and returns owned versions list.

Trait Implementations§

Source§

impl Debug for Versions

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Versions

Source§

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

Deserialize this value from the given Serde deserializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

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

Source§

impl<T> ErasedDestructor for T
where T: 'static,