struct_db/
item.rs

1pub trait SDBItem: Sized {
2    fn struct_db_schema() -> crate::Schema;
3    fn struct_db_primary_key(&self) -> Vec<u8>;
4    fn struct_db_keys(&self) -> std::collections::HashMap<&'static str, Vec<u8>>;
5    fn struct_db_bincode_encode_to_vec(&self) -> Vec<u8>;
6    fn struct_db_bincode_decode_from_slice(slice: &[u8]) -> Self;
7}
8
9pub trait KeyDefinition: Sized {
10    fn secondary_table_name(&self) -> &'static str;
11}
12
13#[derive(Clone)]
14pub(crate) struct BinaryValue(pub(crate) Vec<u8>);
15
16impl BinaryValue {
17    pub fn inner<T: SDBItem>(&self) -> T {
18        T::struct_db_bincode_decode_from_slice(&self.0)
19    }
20}