pub struct Versions { /* private fields */ }Expand description
A collection of Versions.
Implementations§
Source§impl Versions
impl Versions
Sourcepub async fn async_new(crate_name: &str, user_agent: &str) -> Result<Versions>
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
impl Versions
Sourcepub fn new(crate_name: &str, user_agent: &str) -> Result<Versions>
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
impl Versions
Sourcepub fn max_version(&self) -> Option<&Version>
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();Sourcepub fn max_unyanked_version(&self) -> Option<&Version>
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();Sourcepub fn max_yanked_version(&self) -> Option<&Version>
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();Sourcepub fn max_minor_version(&self, major: u64) -> Option<&Version>
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);Sourcepub fn max_unyanked_minor_version(&self, major: u64) -> Option<&Version>
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);Sourcepub fn max_yanked_minor_version(&self, major: u64) -> Option<&Version>
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);Sourcepub fn max_patch(&self, major: u64, minor: u64) -> Option<&Version>
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);Sourcepub fn max_unyanked_patch(&self, major: u64, minor: u64) -> Option<&Version>
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);Sourcepub fn max_yanked_patch(&self, major: u64, minor: u64) -> Option<&Version>
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);Sourcepub fn newest_version(&self) -> Option<&Version>
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();Sourcepub fn newest_unyanked_version(&self) -> Option<&Version>
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();Sourcepub fn newest_yanked_version(&self) -> Option<&Version>
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();Sourcepub fn versions_mut(&mut self) -> &mut Vec<Version>
pub fn versions_mut(&mut self) -> &mut Vec<Version>
Gets a mutable list of versions that were found.
Sourcepub fn versions_owned(self) -> Vec<Version>
pub fn versions_owned(self) -> Vec<Version>
Takes ownership of self and returns owned versions list.