events: add Vec to variants, drop Display impl
This commit is contained in:
parent
708106ab95
commit
e0643e3fad
@ -13,7 +13,8 @@ pub enum Variant {
|
||||
BigInt(i64),
|
||||
Boolean(bool),
|
||||
String(String),
|
||||
RGB(Rgb<u8>)
|
||||
RGB(Rgb<u8>),
|
||||
Vec(Vec<Variant>)
|
||||
}
|
||||
|
||||
macro_rules! impl_variant_type {
|
||||
@ -44,6 +45,7 @@ impl_variant_type!(u64, BigUInt);
|
||||
impl_variant_type!(bool, Boolean);
|
||||
impl_variant_type!(String, String);
|
||||
impl_variant_type!(Rgb<u8>, RGB);
|
||||
impl_variant_type!(Vec<Variant>, Vec);
|
||||
|
||||
impl<'a> From<&'a str> for Variant {
|
||||
fn from(value: &'a str) -> Self {
|
||||
@ -51,22 +53,6 @@ impl<'a> From<&'a str> for Variant {
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for Variant {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Variant::BigInt(i) => (i as &dyn Display).fmt(f),
|
||||
Variant::BigUInt(i) => (i as &dyn Display).fmt(f),
|
||||
Variant::Boolean(i) => (i as &dyn Display).fmt(f),
|
||||
Variant::Byte(i) => (i as &dyn Display).fmt(f),
|
||||
Variant::Int(i) => (i as &dyn Display).fmt(f),
|
||||
Variant::String(i) => (i as &dyn Display).fmt(f),
|
||||
Variant::UInt(i) => (i as &dyn Display).fmt(f),
|
||||
Variant::SignedByte(b) => (b as &dyn Display).fmt(f),
|
||||
Variant::RGB(rgb) => f.write_fmt(format_args!("[{}, {}, {}]", rgb.r, rgb.g, rgb.b)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum Event {
|
||||
ReadyToRock,
|
||||
|
Loading…
x
Reference in New Issue
Block a user