7
7
//! let store = RedisSessionStore::new("redis://127.0.0.1/")?;
8
8
//!
9
9
//! let session = Session::new();
10
- //! session.insert("key".into() , "value".into()) ;
10
+ //! session.insert("key", "value")? ;
11
11
//!
12
12
//! let cookie_value = store.store_session(session).await.unwrap();
13
13
//! let session = store.load_session(cookie_value).await.unwrap();
14
- //! assert_eq!(session.get("key").unwrap(), "value");
14
+ //! assert_eq!(& session.get::<String> ("key").unwrap(), "value");
15
15
//! # Ok(()) }) }
16
16
//! ```
17
17
@@ -181,13 +181,13 @@ mod tests {
181
181
async fn creating_a_new_session_with_no_expiry ( ) -> Result {
182
182
let store = test_store ( ) . await ;
183
183
let session = Session :: new ( ) ;
184
- session. insert ( "key" . into ( ) , "value" . into ( ) ) ;
184
+ session. insert ( "key" , "value" ) ? ;
185
185
let cloned = session. clone ( ) ;
186
186
let cookie_value = store. store_session ( session) . await . unwrap ( ) ;
187
187
188
188
let loaded_session = store. load_session ( cookie_value) . await . unwrap ( ) ;
189
189
assert_eq ! ( cloned. id( ) , loaded_session. id( ) ) ;
190
- assert_eq ! ( "value" , loaded_session. get( "key" ) . unwrap( ) ) ;
190
+ assert_eq ! ( "value" , & loaded_session. get:: < String > ( "key" ) . unwrap( ) ) ;
191
191
192
192
assert ! ( !loaded_session. is_expired( ) ) ;
193
193
Ok ( ( ) )
@@ -198,15 +198,15 @@ mod tests {
198
198
let store = test_store ( ) . await ;
199
199
let session = Session :: new ( ) ;
200
200
201
- session. insert ( "key" . into ( ) , "value" . into ( ) ) ;
201
+ session. insert ( "key" , "value" ) ? ;
202
202
let cookie_value = store. store_session ( session) . await . unwrap ( ) ;
203
203
204
204
let session = store. load_session ( cookie_value. clone ( ) ) . await . unwrap ( ) ;
205
- session. insert ( "key" . into ( ) , "other value" . into ( ) ) ;
205
+ session. insert ( "key" , "other value" ) ? ;
206
206
assert_eq ! ( None , store. store_session( session) . await ) ;
207
207
208
208
let session = store. load_session ( cookie_value. clone ( ) ) . await . unwrap ( ) ;
209
- assert_eq ! ( session. get( "key" ) . unwrap( ) , "other value" ) ;
209
+ assert_eq ! ( & session. get:: < String > ( "key" ) . unwrap( ) , "other value" ) ;
210
210
211
211
assert_eq ! ( 1 , store. count( ) . await . unwrap( ) ) ;
212
212
Ok ( ( ) )
@@ -247,7 +247,7 @@ mod tests {
247
247
let store = test_store ( ) . await ;
248
248
let mut session = Session :: new ( ) ;
249
249
session. expire_in ( Duration :: from_secs ( 3 ) ) ;
250
- session. insert ( "key" . into ( ) , "value" . into ( ) ) ;
250
+ session. insert ( "key" , "value" ) ? ;
251
251
let cloned = session. clone ( ) ;
252
252
253
253
let cookie_value = store. store_session ( session) . await . unwrap ( ) ;
@@ -256,7 +256,7 @@ mod tests {
256
256
257
257
let loaded_session = store. load_session ( cookie_value. clone ( ) ) . await . unwrap ( ) ;
258
258
assert_eq ! ( cloned. id( ) , loaded_session. id( ) ) ;
259
- assert_eq ! ( "value" , loaded_session. get( "key" ) . unwrap( ) ) ;
259
+ assert_eq ! ( "value" , & loaded_session. get:: < String > ( "key" ) . unwrap( ) ) ;
260
260
261
261
assert ! ( !loaded_session. is_expired( ) ) ;
262
262
@@ -312,15 +312,15 @@ mod tests {
312
312
313
313
let session = Session :: new ( ) ;
314
314
315
- session. insert ( "key" . into ( ) , "value" . into ( ) ) ;
315
+ session. insert ( "key" , "value" ) ? ;
316
316
let cookie_value = store. store_session ( session) . await . unwrap ( ) ;
317
317
318
318
let session = store. load_session ( cookie_value. clone ( ) ) . await . unwrap ( ) ;
319
- session. insert ( "key" . into ( ) , "other value" . into ( ) ) ;
319
+ session. insert ( "key" , "other value" ) ? ;
320
320
assert_eq ! ( None , store. store_session( session) . await ) ;
321
321
322
322
let session = store. load_session ( cookie_value. clone ( ) ) . await . unwrap ( ) ;
323
- assert_eq ! ( session. get( "key" ) . unwrap( ) , "other value" ) ;
323
+ assert_eq ! ( & session. get:: < String > ( "key" ) . unwrap( ) , "other value" ) ;
324
324
325
325
assert_eq ! ( 4 , store. count( ) . await . unwrap( ) ) ;
326
326
0 commit comments