use serde::{Deserialize, Serialize};
pub trait Storable:
Serialize + for<'lt> Deserialize<'lt> + Clone + std::fmt::Debug + Ord + PartialEq
{
fn type_description() -> String;
}
impl Storable for String {
fn type_description() -> String {
"string".to_string()
}
}
impl<T: Storable> Storable for Option<T> {
fn type_description() -> String {
format!("option-{}", <T as Storable>::type_description())
}
}
impl<T: Storable, U: Storable> Storable for (T, U) {
fn type_description() -> String {
format!(
"tuple-{}-{}",
<T as Storable>::type_description(),
<U as Storable>::type_description()
)
}
}
impl Storable for i32 {
fn type_description() -> String {
"i32".to_string()
}
}
impl Storable for usize {
fn type_description() -> String {
"usize".to_string()
}
}