use core::fmt::Debug; use core::fmt::Display; use alloc::string::{String, ToString}; use super::type_of; #[derive(PartialEq, Eq, Hash, Debug, Clone)] pub enum Types { Null, Byte(u8), String(String), } impl Types { pub fn new(value: T) -> Self { let type_of = type_of(&value); match type_of { "&str" => return Self::String(value.to_string()), "alloc::string::String" => return Self::String(value.to_string()), type_name => { panic!( " Invalid type: {} {}", value, type_name ); } } } } impl From for Types { fn from(value: u8) -> Self { Self::Byte(value) } } impl From for Types { fn from(value: String) -> Self { Self::String(value) } } impl From<&str> for Types { fn from(value: &str) -> Self { Self::String(value.to_string()) } }