File tree Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -74,12 +74,22 @@ impl Pkcs11Impl {
7474 FunctionList :: V3_2 ( l) => l,
7575 }
7676 }
77+ }
78+
79+ /// Main PKCS11 context. Should usually be unique per application.
80+ #[ derive( Debug ) ]
81+ pub struct Pkcs11 {
82+ pub ( crate ) impl_ : Pkcs11Impl ,
83+ initialized : RwLock < bool > ,
84+ }
7785
86+ impl Pkcs11 {
7887 // Private finalize call
7988 #[ inline( always) ]
80- fn finalize ( & self ) -> Result < ( ) > {
89+ fn finalize_ref ( & self ) -> Result < ( ) > {
8190 unsafe {
8291 Rv :: from ( self
92+ . impl_
8393 . get_function_list ( )
8494 . C_Finalize
8595 . ok_or ( Error :: NullFunctionPointer ) ?(
@@ -90,21 +100,14 @@ impl Pkcs11Impl {
90100 }
91101}
92102
93- impl Drop for Pkcs11Impl {
103+ impl Drop for Pkcs11 {
94104 fn drop ( & mut self ) {
95- if let Err ( e) = self . finalize ( ) {
105+ if let Err ( e) = self . finalize_ref ( ) {
96106 error ! ( "Failed to finalize: {}" , e) ;
97107 }
98108 }
99109}
100110
101- /// Main PKCS11 context. Should usually be unique per application.
102- #[ derive( Debug ) ]
103- pub struct Pkcs11 {
104- pub ( crate ) impl_ : Pkcs11Impl ,
105- initialized : RwLock < bool > ,
106- }
107-
108111impl Pkcs11 {
109112 /// Instantiate a new context from the path of a PKCS11 dynamic library implementation.
110113 pub fn new < P > ( filename : P ) -> Result < Self >
You can’t perform that action at this time.
0 commit comments