1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//! Refresh-token storage trait.
//!
//! Mirrors the
//! [`core.TokenStore`](https://github.com/LdDl/echo-jwt/blob/master/core/store.go)
//! interface from the Go implementation. Implementations live in the
//! [`crate::store`] module.
use async_trait;
use crateJwtError;
/// Async trait defining the contract for refresh-token storage backends.
///
/// All methods are object-safe so that `Arc<dyn TokenStore>` can be used at
/// runtime to swap implementations (in-memory, Redis, etc.).
///
/// # Provided implementations
///
/// * [`crate::store::InMemoryRefreshTokenStore`] - thread-safe `HashMap`
/// behind a [`tokio::sync::RwLock`].
/// * `RedisRefreshTokenStore` - Redis-backed store
/// (requires the `redis-store` feature).
///
/// # Examples
///
/// ```
/// use actix_jwt::core::TokenStore;
/// use actix_jwt::store::InMemoryRefreshTokenStore;
///
/// # #[tokio::main]
/// # async fn main() {
/// let store: Box<dyn TokenStore> = Box::new(InMemoryRefreshTokenStore::new());
/// let count = store.count().await.unwrap();
/// assert_eq!(count, 0);
/// # }
/// ```