All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
31 lines
771 B
Rust
31 lines
771 B
Rust
use serde::{Deserialize, Serialize};
|
|
use structopt::clap::arg_enum;
|
|
|
|
arg_enum! {
|
|
#[derive(Serialize, Deserialize, Debug, Clone, Copy)]
|
|
pub enum SpeedUnit {
|
|
Kmh,
|
|
Ms,
|
|
Mph,
|
|
Knots
|
|
}
|
|
}
|
|
|
|
pub fn speed_to_unit_string(speed_unit: &SpeedUnit) -> String {
|
|
match speed_unit {
|
|
SpeedUnit::Kmh => "km/h".to_string(),
|
|
SpeedUnit::Ms => "m/s".to_string(),
|
|
SpeedUnit::Mph => "mp/h".to_string(),
|
|
SpeedUnit::Knots => "knots".to_string(),
|
|
}
|
|
}
|
|
|
|
pub fn speed_to_string(speed_unit: &SpeedUnit) -> String {
|
|
match speed_unit {
|
|
SpeedUnit::Kmh => "kmh".to_string(),
|
|
SpeedUnit::Ms => "ms".to_string(),
|
|
SpeedUnit::Mph => "mph".to_string(),
|
|
SpeedUnit::Knots => "kn".to_string(),
|
|
}
|
|
}
|