#![allow(unused, clippy::match_single_binding)]
use std::fmt;
#[derive(Clone, Copy, PartialEq)]
pub struct Tone(pub u8);
impl Tone {
pub const OFF: Tone = Tone(0);
pub const TONE: Tone = Tone(1);
pub const VIBRATE: Tone = Tone(2);
pub const TONE_AND_VIBRATE: Tone = Tone(3);
}
impl Default for Tone {
fn default() -> Self {
Self(u8::MAX)
}
}
impl fmt::Display for Tone {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.0 {
0 => write!(f, "off"),
1 => write!(f, "tone"),
2 => write!(f, "vibrate"),
3 => write!(f, "tone_and_vibrate"),
_ => write!(f, "Tone({})", self.0),
}
}
}
impl fmt::Debug for Tone {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.0 {
0 => write!(f, "Tone::OFF(0)"),
1 => write!(f, "Tone::TONE(1)"),
2 => write!(f, "Tone::VIBRATE(2)"),
3 => write!(f, "Tone::TONE_AND_VIBRATE(3)"),
_ => write!(f, "Tone({})", self.0),
}
}
}