@@ -14,6 +14,7 @@ use log::error;
14
14
use std:: collections:: HashMap ;
15
15
use std:: convert:: TryInto ;
16
16
use std:: fmt:: Formatter ;
17
+ use std:: marker:: PhantomData ;
17
18
use std:: ops:: Deref ;
18
19
19
20
mod decryption;
@@ -35,46 +36,46 @@ pub use flags::*;
35
36
/// threads. A Session needs to be created in its own thread or to be passed by ownership to
36
37
/// another thread.
37
38
#[ derive( Debug ) ]
38
- pub struct Session < ' a > {
39
+ pub struct Session {
39
40
handle : CK_SESSION_HANDLE ,
40
- client : & ' a Pkcs11 ,
41
+ client : Pkcs11 ,
41
42
// This is not used but to prevent Session to automatically implement Send and Sync
42
- _guard : * mut u32 ,
43
+ _guard : PhantomData < * mut u32 > ,
43
44
}
44
45
45
- impl std:: fmt:: Display for Session < ' _ > {
46
+ impl std:: fmt:: Display for Session {
46
47
fn fmt ( & self , f : & mut Formatter < ' _ > ) -> std:: fmt:: Result {
47
48
write ! ( f, "{}" , self . handle)
48
49
}
49
50
}
50
51
51
- impl std:: fmt:: LowerHex for Session < ' _ > {
52
+ impl std:: fmt:: LowerHex for Session {
52
53
fn fmt ( & self , f : & mut Formatter < ' _ > ) -> std:: fmt:: Result {
53
54
write ! ( f, "{:08x}" , self . handle)
54
55
}
55
56
}
56
57
57
- impl std:: fmt:: UpperHex for Session < ' _ > {
58
+ impl std:: fmt:: UpperHex for Session {
58
59
fn fmt ( & self , f : & mut Formatter < ' _ > ) -> std:: fmt:: Result {
59
60
write ! ( f, "{:08X}" , self . handle)
60
61
}
61
62
}
62
63
63
64
// Session does not implement Sync to prevent the same Session instance to be used from multiple
64
65
// threads.
65
- unsafe impl < ' a > Send for Session < ' a > { }
66
+ unsafe impl Send for Session { }
66
67
67
- impl < ' a > Session < ' a > {
68
- pub ( crate ) fn new ( handle : CK_SESSION_HANDLE , client : & ' a Pkcs11 ) -> Self {
68
+ impl Session {
69
+ pub ( crate ) fn new ( handle : CK_SESSION_HANDLE , client : Pkcs11 ) -> Self {
69
70
Session {
70
71
handle,
71
72
client,
72
- _guard : std :: ptr :: null_mut :: < u32 > ( ) ,
73
+ _guard : PhantomData ,
73
74
}
74
75
}
75
76
}
76
77
77
- impl Session < ' _ > {
78
+ impl Session {
78
79
/// Initialize the normal user's pin for a token
79
80
pub fn init_pin ( & self , pin : & str ) -> Result < ( ) > {
80
81
slot_token_management:: init_pin ( self , pin)
@@ -339,11 +340,11 @@ impl Session<'_> {
339
340
}
340
341
341
342
pub ( crate ) fn client ( & self ) -> & Pkcs11 {
342
- self . client
343
+ & self . client
343
344
}
344
345
}
345
346
346
- impl Drop for Session < ' _ > {
347
+ impl Drop for Session {
347
348
fn drop ( & mut self ) {
348
349
if let Err ( e) = session_management:: close_private ( self ) {
349
350
error ! ( "Failed to close session: {}" , e) ;
0 commit comments