@@ -39,7 +39,11 @@ impl AuthBackend {
3939 let path = TextCredentialStore :: default_file ( ) ?;
4040 match TextCredentialStore :: read ( & path) {
4141 Ok ( ( store, lock) ) => Ok ( Self :: TextStore ( store, lock) ) ,
42- Err ( TomlCredentialError :: Io ( err) ) if err. kind ( ) == std:: io:: ErrorKind :: NotFound => {
42+ Err ( err)
43+ if err
44+ . as_io_error ( )
45+ . is_some_and ( |err| err. kind ( ) == std:: io:: ErrorKind :: NotFound ) =>
46+ {
4347 Ok ( Self :: TextStore (
4448 TextCredentialStore :: default ( ) ,
4549 TextCredentialStore :: lock ( & path) ?,
@@ -86,6 +90,21 @@ pub enum TomlCredentialError {
8690 TokenNotUnicode ( #[ from] std:: string:: FromUtf8Error ) ,
8791}
8892
93+ impl TomlCredentialError {
94+ pub fn as_io_error ( & self ) -> Option < & std:: io:: Error > {
95+ match self {
96+ Self :: Io ( err) => Some ( err) ,
97+ Self :: LockedFile ( err) => err. as_io_error ( ) ,
98+ Self :: ParseError ( _)
99+ | Self :: SerializeError ( _)
100+ | Self :: BasicAuthError ( _)
101+ | Self :: BearerAuthError ( _)
102+ | Self :: CredentialsDirError
103+ | Self :: TokenNotUnicode ( _) => None ,
104+ }
105+ }
106+ }
107+
89108#[ derive( Debug , Error ) ]
90109pub enum BasicAuthError {
91110 #[ error( "`username` is required with `scheme = basic`" ) ]
0 commit comments