@@ -27,9 +27,10 @@ if matches!(persistence, credential::CredentialPersistence::UntilDelete) {
27
27
}
28
28
```
29
29
*/
30
- use super :: Result ;
31
30
use std:: any:: Any ;
32
31
32
+ use super :: Result ;
33
+
33
34
/// The API that [credentials](Credential) implement.
34
35
pub trait CredentialApi {
35
36
/// Set the credential's password (a string).
@@ -66,17 +67,30 @@ pub trait CredentialApi {
66
67
/// can do platform-specific things with it (e.g.,
67
68
/// query its attributes in the underlying store).
68
69
fn as_any ( & self ) -> & dyn Any ;
69
- }
70
70
71
- impl std:: fmt:: Debug for Credential {
72
- fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
73
- self . as_any ( ) . fmt ( f)
71
+ /// The Debug trait call for the object.
72
+ ///
73
+ /// This is used to implement the Debug trait on this type; it
74
+ /// allows generic code to provide debug printing as provided by
75
+ /// the underlying concrete object.
76
+ ///
77
+ /// We provide a (useless) default implementation for backward
78
+ /// compatibility with existing implementors who may have not
79
+ /// implemented the Debug trait for their credential objects
80
+ fn debug_fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
81
+ std:: fmt:: Debug :: fmt ( self . as_any ( ) , f)
74
82
}
75
83
}
76
84
77
85
/// A thread-safe implementation of the [Credential API](CredentialApi).
78
86
pub type Credential = dyn CredentialApi + Send + Sync ;
79
87
88
+ impl std:: fmt:: Debug for Credential {
89
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
90
+ self . debug_fmt ( f)
91
+ }
92
+ }
93
+
80
94
/// A descriptor for the lifetime of stored credentials, returned from
81
95
/// a credential store's [persistence](CredentialBuilderApi::persistence) call.
82
96
#[ non_exhaustive]
0 commit comments