Skip to main content

openauth_core/options/
storage.rs

1use std::future::Future;
2use std::pin::Pin;
3
4use crate::error::OpenAuthError;
5
6pub type SecondaryStorageFuture<'a, T> =
7    Pin<Box<dyn Future<Output = Result<T, OpenAuthError>> + Send + 'a>>;
8
9/// Async key-value storage for plugin data that can live outside the primary database.
10pub trait SecondaryStorage: Send + Sync + 'static {
11    fn get<'a>(&'a self, key: &'a str) -> SecondaryStorageFuture<'a, Option<String>>;
12
13    fn set<'a>(
14        &'a self,
15        key: &'a str,
16        value: String,
17        ttl_seconds: Option<u64>,
18    ) -> SecondaryStorageFuture<'a, ()>;
19
20    fn delete<'a>(&'a self, key: &'a str) -> SecondaryStorageFuture<'a, ()>;
21}