@@ -20,14 +20,16 @@ use std::convert::{TryFrom, TryInto};
2020
2121use crate :: error:: RvError :: BufferTooSmall ;
2222
23+ use super :: Function ;
24+
2325impl Pkcs11 {
2426 #[ inline( always) ]
2527 fn get_slots ( & self , with_token : CK_BBOOL ) -> Result < Vec < Slot > > {
2628 let mut slot_count = 0 ;
2729 let rval = unsafe {
2830 get_pkcs11 ! ( self , C_GetSlotList ) ( with_token, std:: ptr:: null_mut ( ) , & mut slot_count)
2931 } ;
30- Rv :: from ( rval) . into_result ( ) ?;
32+ Rv :: from ( rval) . into_result ( Function :: GetSlotList ) ?;
3133
3234 let mut slots;
3335 loop {
@@ -41,7 +43,7 @@ impl Pkcs11 {
4143 // and we want to loop again with a resized buffer.
4244 if !matches ! ( Rv :: from( rval) , Rv :: Error ( BufferTooSmall ) ) {
4345 // Account for other possible error types
44- Rv :: from ( rval) . into_result ( ) ?;
46+ Rv :: from ( rval) . into_result ( Function :: GetSlotList ) ?;
4547 // Otherwise, we have a valid list to process
4648 break ;
4749 }
@@ -92,7 +94,7 @@ impl Pkcs11 {
9294 pin. expose_secret ( ) . len ( ) . try_into ( ) ?,
9395 label. as_ptr ( ) as * mut u8 ,
9496 ) )
95- . into_result ( )
97+ . into_result ( Function :: InitToken )
9698 }
9799 }
98100
@@ -104,7 +106,7 @@ impl Pkcs11 {
104106 slot. into ( ) ,
105107 & mut slot_info,
106108 ) )
107- . into_result ( ) ?;
109+ . into_result ( Function :: GetSlotInfo ) ?;
108110 Ok ( SlotInfo :: from ( slot_info) )
109111 }
110112 }
@@ -117,7 +119,7 @@ impl Pkcs11 {
117119 slot. into ( ) ,
118120 & mut token_info,
119121 ) )
120- . into_result ( ) ?;
122+ . into_result ( Function :: GetTokenInfo ) ?;
121123 TokenInfo :: try_from ( token_info)
122124 }
123125 }
@@ -132,7 +134,7 @@ impl Pkcs11 {
132134 std:: ptr:: null_mut ( ) ,
133135 & mut mechanism_count,
134136 ) )
135- . into_result ( ) ?;
137+ . into_result ( Function :: GetMechanismList ) ?;
136138 }
137139
138140 let mut mechanisms = vec ! [ 0 ; mechanism_count. try_into( ) ?] ;
@@ -143,7 +145,7 @@ impl Pkcs11 {
143145 mechanisms. as_mut_ptr ( ) ,
144146 & mut mechanism_count,
145147 ) )
146- . into_result ( ) ?;
148+ . into_result ( Function :: GetMechanismList ) ?;
147149 }
148150
149151 // Truncate mechanisms if count decreased.
@@ -164,7 +166,7 @@ impl Pkcs11 {
164166 type_. into ( ) ,
165167 & mut mechanism_info,
166168 ) )
167- . into_result ( ) ?;
169+ . into_result ( Function :: GetMechanismInfo ) ?;
168170 Ok ( MechanismInfo :: from ( mechanism_info) )
169171 }
170172 }
@@ -174,7 +176,7 @@ impl Pkcs11 {
174176 let mut slot: CK_SLOT_ID = 0 ;
175177 let wait_for_slot_event = get_pkcs11 ! ( self , C_WaitForSlotEvent ) ;
176178 let rv = wait_for_slot_event ( flags, & mut slot, std:: ptr:: null_mut ( ) ) ;
177- Rv :: from ( rv) . into_result ( ) ?;
179+ Rv :: from ( rv) . into_result ( Function :: WaitForSlotEvent ) ?;
178180 Ok ( Slot :: new ( slot) )
179181 }
180182 }
@@ -187,7 +189,7 @@ impl Pkcs11 {
187189 /// Get the latest slot event (insertion or removal of a token)
188190 pub fn get_slot_event ( & self ) -> Result < Option < Slot > > {
189191 match self . wait_for_slot_event_impl ( CKF_DONT_BLOCK ) {
190- Err ( Error :: Pkcs11 ( RvError :: NoEvent ) ) => Ok ( None ) ,
192+ Err ( Error :: Pkcs11 ( RvError :: NoEvent , Function :: WaitForSlotEvent ) ) => Ok ( None ) ,
191193 Ok ( slot) => Ok ( Some ( slot) ) ,
192194 Err ( x) => Err ( x) ,
193195 }
0 commit comments