Skip to main content

check_version

Function check_version 

Source
pub fn check_version(
    name: &str,
    current_version: &str,
    interval: Duration,
) -> Result<(), Box<dyn Error>>
Expand description

Checks if there exists an update by checking against crates.io and notifies the user by printing to stdout

§Arguments

  • name - The name of the crate, you can use env!("CARGO_PKG_NAME")
  • current_version - The version of the CLI, use env!("CARGO_PKG_VERSION")
  • interval - Duration representing the interval.

§Examples

use update_notifier::check_version;

check_version(
  env!("CARGO_PKG_NAME"),
  env!("CARGO_PKG_VERSION"),
  std::time::Duration::from_secs(0),
  ).ok();

§Errors

Could error either if your plateform does not have a config directory or if an the crate name is not in the registry