@@ -60,7 +60,7 @@ impl DeviceCredentialLocation for FileSystemPath {
6060 if Path :: new ( & self . path ) . exists ( ) {
6161 Some ( Ok ( Box :: new ( self . clone ( ) ) ) )
6262 } else {
63- log:: trace!( "No (device credential) file exists at {}" , & self . path) ;
63+ log:: trace!( "No (device credential) file exists at {}" , self . path) ;
6464 None
6565 }
6666 }
@@ -69,17 +69,17 @@ impl DeviceCredentialLocation for FileSystemPath {
6969impl UsableDeviceCredentialLocation for FileSystemPath {
7070 fn read ( & self ) -> Result < Box < dyn DeviceCredential > > {
7171 let contents = fs:: read ( & self . path )
72- . with_context ( || format ! ( "Error reading (device credential) file at {}" , & self . path) ) ?;
72+ . with_context ( || format ! ( "Error reading (device credential) file at {}" , self . path) ) ?;
7373 let fdc = FileDeviceCredential :: deserialize_data ( & contents)
74- . with_context ( || format ! ( "Error parsing device credential from {}" , & self . path) ) ?;
74+ . with_context ( || format ! ( "Error parsing device credential from {}" , self . path) ) ?;
7575 Ok ( Box :: new ( fdc) )
7676 }
7777
7878 fn deactivate ( & self ) -> Result < ( ) > {
7979 match self . deactivation_method {
8080 DeactivationMethod :: None => Ok ( ( ) ) ,
8181 DeactivationMethod :: Delete => fs:: remove_file ( & self . path )
82- . with_context ( || format ! ( "Error deleting file at {}" , & self . path) ) ,
82+ . with_context ( || format ! ( "Error deleting file at {}" , self . path) ) ,
8383 DeactivationMethod :: Deactivate => self . perform_deactivation ( ) ,
8484 }
8585 }
@@ -88,9 +88,9 @@ impl UsableDeviceCredentialLocation for FileSystemPath {
8888impl FileSystemPath {
8989 fn perform_deactivation ( & self ) -> Result < ( ) > {
9090 let contents = fs:: read ( & self . path )
91- . with_context ( || format ! ( "Error reading (device credential) file at {}" , & self . path) ) ?;
91+ . with_context ( || format ! ( "Error reading (device credential) file at {}" , self . path) ) ?;
9292 let mut fdc = FileDeviceCredential :: deserialize_data ( & contents)
93- . with_context ( || format ! ( "Error parsing device credential from {}" , & self . path) ) ?;
93+ . with_context ( || format ! ( "Error parsing device credential from {}" , self . path) ) ?;
9494
9595 fdc. active = false ;
9696 let new_dc_contents = fdc
@@ -102,7 +102,7 @@ impl FileSystemPath {
102102
103103 fn write ( & self , new_contents : Vec < u8 > ) -> Result < ( ) > {
104104 fs:: write ( & self . path , new_contents)
105- . with_context ( || format ! ( "Error writing to file at {}" , & self . path) )
105+ . with_context ( || format ! ( "Error writing to file at {}" , self . path) )
106106 }
107107}
108108
@@ -113,23 +113,24 @@ struct FileSystemPathEnv {
113113
114114impl DeviceCredentialLocation for FileSystemPathEnv {
115115 fn resolve ( & self ) -> Option < Result < Box < dyn UsableDeviceCredentialLocation > > > {
116- let env_val = match env :: var_os ( & self . env_var ) {
117- None => return None ,
118- Some ( v ) => match v. into_string ( ) {
116+ let env_val = {
117+ let v = env :: var_os ( & self . env_var ) ? ;
118+ match v. into_string ( ) {
119119 Ok ( s) => s,
120120 Err ( _) => return Some ( Err ( anyhow ! ( "Invalid environment variable value" ) ) ) ,
121- } ,
121+ }
122122 } ;
123- let deactivation_method = match env:: var_os ( format ! ( "{}_DELETE" , & self . env_var) ) {
124- None => match env:: var_os ( format ! ( "{}_DEACTIVATE" , & self . env_var) ) {
123+
124+ let deactivation_method = match env:: var_os ( format ! ( "{}_DELETE" , self . env_var) ) {
125+ None => match env:: var_os ( format ! ( "{}_DEACTIVATE" , self . env_var) ) {
125126 None => DeactivationMethod :: None ,
126127 Some ( _) => DeactivationMethod :: Deactivate ,
127128 } ,
128129 Some ( _) => DeactivationMethod :: Delete ,
129130 } ;
130131 log:: trace!(
131132 "Resolved environment variable {} to filesystem path {} (deactivation method {:?})" ,
132- & self . env_var,
133+ self . env_var,
133134 & env_val,
134135 & deactivation_method,
135136 ) ;
0 commit comments