dispnet_storage/lib.rs
1pub mod filestorage;
2pub mod policy;
3pub mod storage_manager;
4
5/// Successful result on the storage provider `get` function.
6pub struct GetData {
7 /// Key of the entry.
8 pub key: String,
9 /// Byte size of the entry.
10 pub size: usize,
11 /// Raw data of the entry.
12 pub data: Vec<u8>
13}
14
15/// Successful result on the storage provider save function.
16pub struct SaveData {
17 /// Key of the saved entry.
18 pub key: String,
19 /// Byte size of the entry.
20 pub size: usize,
21}
22
23/// This `trait`must be implemented to use a `struct` as a storage provider.
24pub trait StorageProvider {
25 /// Get data from a storage provider with a key.
26 fn get(self: &Self, key: &str) -> Result<GetData, String>;
27 /// Save data to the storage provider.
28 fn save(self: &Self, key: &str, raw: Vec<u8>) -> Result<SaveData, String>;
29 /// Queue an entry for deletion in the storage provider.
30 fn delete(self: &Self, key: &str);
31 /// Execute free.
32 fn free(self: &Self);
33 /// Executes force free.
34 fn force_free(self: &Self, all: bool);
35}