1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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()
    }
}