use semver::{Version, VersionReq};
use crate::error::Result;
mod process;
pub mod runner;
#[allow(clippy::module_name_repetitions)]
pub use self::runner::{ExecutableRunner, Output};
pub trait Executable {
fn get_name(&self) -> String;
fn get_verification_hint(&self) -> String;
fn get_version_hint(&self) -> String;
fn get_required_version(&self) -> Option<VersionReq>;
fn get_current_version(&self) -> Result<Version>
where
Self: Sized,
{
self::runner::parse_executable_version(self)
}
}
pub struct Cargo;
impl Executable for Cargo {
fn get_name(&self) -> String {
String::from("cargo")
}
fn get_verification_hint(&self) -> String {
String::from("Please make sure you have it installed and in PATH")
}
fn get_version_hint(&self) -> String {
String::from("Please update Rust and Cargo to latest nightly versions")
}
fn get_required_version(&self) -> Option<VersionReq> {
Some(VersionReq::parse(">= 1.34.0-nightly").unwrap())
}
fn get_current_version(&self) -> Result<Version> {
self::runner::parse_executable_version(self).map(|mut version| {
version.pre = semver::Prerelease::EMPTY;
version
})
}
}