sessions_core/
store.rs

1use std::{fmt, ops::Deref};
2
3/// Sessions Config
4pub struct Store<S, G, V> {
5    /// Current Storage
6    pub storage: S,
7    /// Generates session id
8    pub generate: G,
9    /// Verifes session id
10    pub verify: V,
11}
12
13impl<S, G, V> Store<S, G, V> {
14    pub fn new(storage: S, generate: G, verify: V) -> Self {
15        Self {
16            storage,
17            generate,
18            verify,
19        }
20    }
21
22    /// Gets current storage
23    pub fn storage(&self) -> &S {
24        &self.storage
25    }
26}
27
28impl<S, G, V> AsRef<S> for Store<S, G, V> {
29    fn as_ref(&self) -> &S {
30        &self.storage
31    }
32}
33
34impl<S, G, V> Deref for Store<S, G, V> {
35    type Target = S;
36
37    fn deref(&self) -> &S {
38        &self.storage
39    }
40}
41
42impl<S, G, V> fmt::Debug for Store<S, G, V> {
43    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
44        f.debug_struct("Store").finish()
45    }
46}