kitsune2_api/
peer_meta_store.rs1use crate::{builder, config, BoxFut, K2Result, Timestamp, Url};
2use futures::future::BoxFuture;
3use std::sync::Arc;
4
5pub trait PeerMetaStore: 'static + Send + Sync + std::fmt::Debug {
9 fn put(
11 &self,
12 peer: Url,
13 key: String,
14 value: bytes::Bytes,
15 expiry: Option<Timestamp>,
16 ) -> BoxFuture<'_, K2Result<()>>;
17
18 fn get(
20 &self,
21 peer: Url,
22 key: String,
23 ) -> BoxFuture<'_, K2Result<Option<bytes::Bytes>>>;
24
25 fn delete(&self, peer: Url, key: String) -> BoxFuture<'_, K2Result<()>>;
27}
28
29pub type DynPeerMetaStore = Arc<dyn PeerMetaStore>;
31
32pub trait PeerMetaStoreFactory:
34 'static + Send + Sync + std::fmt::Debug
35{
36 fn default_config(&self, config: &mut config::Config) -> K2Result<()>;
39
40 fn validate_config(&self, config: &config::Config) -> K2Result<()>;
42
43 fn create(
45 &self,
46 builder: Arc<builder::Builder>,
47 ) -> BoxFut<'static, K2Result<DynPeerMetaStore>>;
48}
49
50pub type DynPeerMetaStoreFactory = Arc<dyn PeerMetaStoreFactory>;