common_data_model/
custom_traits.rs1use serde::{Deserialize, Serialize};
2
3pub trait CustomSerializer<T> {
7 fn to_json_string(&self) -> String
12 where
13 Self: Serialize,
14 Self: Sized,
15 {
16 serde_json::to_string(&self).expect("Error during serialization")
17 }
18 fn from_json_string(data_string: String) -> T
28 where
29 T: for<'a> Deserialize<'a>,
30 {
31 serde_json::from_str(&data_string).expect("Error during deserialization")
32 }
33}
34
35pub trait IMacVendorCache {
36 fn new() -> Self;
37 fn add(&self, mac_addr: String, vendor_name: String);
38 fn contains(&self, mac_addr: &String) -> bool;
39 fn get(&self, mac_addr: &String) -> String;
40 fn length(&self) -> usize;
41}