6
6
//! # fn main() -> async_session::Result { async_std::task::block_on(async {
7
7
//! let store = RedisSessionStore::new("redis://127.0.0.1/")?;
8
8
//!
9
- //! let session = Session::new();
9
+ //! let mut session = Session::new();
10
10
//! session.insert("key", "value")?;
11
11
//!
12
12
//! let cookie_value = store.store_session(session).await.unwrap();
25
25
unused_qualifications
26
26
) ]
27
27
28
- use async_session:: { async_trait, serde_json, Result , Session , SessionStore } ;
28
+ use async_session:: { async_trait, id_from_cookie_value , serde_json, Result , Session , SessionStore } ;
29
29
use redis:: { aio:: Connection , AsyncCommands , Client , IntoConnectionInfo , RedisResult } ;
30
30
31
31
/// # RedisSessionStore
@@ -116,7 +116,7 @@ impl RedisSessionStore {
116
116
#[ async_trait]
117
117
impl SessionStore for RedisSessionStore {
118
118
async fn load_session ( & self , cookie_value : String ) -> Option < Session > {
119
- let id = Session :: id_from_cookie_value ( & cookie_value) . ok ( ) ?;
119
+ let id = id_from_cookie_value ( & cookie_value) . ok ( ) ?;
120
120
let mut connection = self . connection ( ) . await . ok ( ) ?;
121
121
let record: Option < String > = connection. get ( self . prefix_key ( id) ) . await . ok ( ) ?;
122
122
match record {
@@ -180,7 +180,7 @@ mod tests {
180
180
#[ async_std:: test]
181
181
async fn creating_a_new_session_with_no_expiry ( ) -> Result {
182
182
let store = test_store ( ) . await ;
183
- let session = Session :: new ( ) ;
183
+ let mut session = Session :: new ( ) ;
184
184
session. insert ( "key" , "value" ) ?;
185
185
let cloned = session. clone ( ) ;
186
186
let cookie_value = store. store_session ( session) . await . unwrap ( ) ;
@@ -196,12 +196,12 @@ mod tests {
196
196
#[ async_std:: test]
197
197
async fn updating_a_session ( ) -> Result {
198
198
let store = test_store ( ) . await ;
199
- let session = Session :: new ( ) ;
199
+ let mut session = Session :: new ( ) ;
200
200
201
201
session. insert ( "key" , "value" ) ?;
202
202
let cookie_value = store. store_session ( session) . await . unwrap ( ) ;
203
203
204
- let session = store. load_session ( cookie_value. clone ( ) ) . await . unwrap ( ) ;
204
+ let mut session = store. load_session ( cookie_value. clone ( ) ) . await . unwrap ( ) ;
205
205
session. insert ( "key" , "other value" ) ?;
206
206
assert_eq ! ( None , store. store_session( session) . await ) ;
207
207
@@ -310,12 +310,12 @@ mod tests {
310
310
store. store_session ( Session :: new ( ) ) . await ;
311
311
}
312
312
313
- let session = Session :: new ( ) ;
313
+ let mut session = Session :: new ( ) ;
314
314
315
315
session. insert ( "key" , "value" ) ?;
316
316
let cookie_value = store. store_session ( session) . await . unwrap ( ) ;
317
317
318
- let session = store. load_session ( cookie_value. clone ( ) ) . await . unwrap ( ) ;
318
+ let mut session = store. load_session ( cookie_value. clone ( ) ) . await . unwrap ( ) ;
319
319
session. insert ( "key" , "other value" ) ?;
320
320
assert_eq ! ( None , store. store_session( session) . await ) ;
321
321
0 commit comments