bytecon_data_store/
lib.rs

1use std::{error::Error, future::Future};
2
3pub mod implementation;
4
5// TODO create DistributedRemoteDataStore (server/client) for splitting out data across multiple possible data stores
6//      a strategy enum could be provide with variants like "evenly divided" (total bytes used on each is equal), "proportionally divided" (current bytes divided by max bytes is equal), "largest first", "smallest first", "fastest first", "slowest first", etc.
7
8pub trait DataStore {
9    type Item;
10    type Key;
11
12    fn initialize(&mut self) -> impl Future<Output = Result<(), Box<dyn Error>>> + Send;
13    fn insert(&mut self, item: Self::Item) -> impl Future<Output = Result<Self::Key, Box<dyn Error>>> + Send;
14    fn get(&self, id: &Self::Key) -> impl Future<Output = Result<Self::Item, Box<dyn Error>>> + Send;
15    fn delete(&self, id: &Self::Key) -> impl Future<Output = Result<(), Box<dyn Error>>> + Send;
16    fn list(&self, page_index: u64, page_size: u64, row_offset: u64) -> impl Future<Output = Result<Vec<Self::Key>, Box<dyn Error>>> + Send;
17    fn bulk_insert(&mut self, items: Vec<Self::Item>) -> impl Future<Output = Result<Vec<Self::Key>, Box<dyn Error>>> + Send;
18    fn bulk_get(&self, ids: &Vec<Self::Key>) -> impl Future<Output = Result<Vec<Self::Item>, Box<dyn Error>>> + Send;
19}