@@ -44,7 +44,10 @@ impl Error {
4444
4545 pub ( crate ) fn pool_cleared_error ( address : & StreamAddress ) -> Self {
4646 ErrorKind :: ConnectionPoolClearedError {
47- message : format ! ( "Conneciton pool for {} cleared during operation execution" , address)
47+ message : format ! (
48+ "Conneciton pool for {} cleared during operation execution" ,
49+ address
50+ ) ,
4851 }
4952 . into ( )
5053 }
@@ -129,10 +132,13 @@ impl Error {
129132
130133 /// Whether an error originated from the server.
131134 pub ( crate ) fn is_server_error ( & self ) -> bool {
132- matches ! ( self . kind. as_ref( ) , ErrorKind :: AuthenticationError { .. }
133- | ErrorKind :: BulkWriteError ( _)
134- | ErrorKind :: CommandError ( _)
135- | ErrorKind :: WriteError ( _) )
135+ matches ! (
136+ self . kind. as_ref( ) ,
137+ ErrorKind :: AuthenticationError { .. }
138+ | ErrorKind :: BulkWriteError ( _)
139+ | ErrorKind :: CommandError ( _)
140+ | ErrorKind :: WriteError ( _)
141+ )
136142 }
137143
138144 /// Returns the labels for this error.
@@ -153,7 +159,9 @@ impl Error {
153159
154160 /// Whether this error contains the specified label.
155161 pub fn contains_label < T : AsRef < str > > ( & self , label : T ) -> bool {
156- self . labels ( ) . iter ( ) . any ( |actual_label| actual_label. as_str ( ) == label. as_ref ( ) )
162+ self . labels ( )
163+ . iter ( )
164+ . any ( |actual_label| actual_label. as_str ( ) == label. as_ref ( ) )
157165 }
158166
159167 /// Returns a copy of this Error with the specified label added.
@@ -373,7 +381,10 @@ impl ErrorKind {
373381 }
374382
375383 pub ( crate ) fn is_network_error ( & self ) -> bool {
376- matches ! ( self , ErrorKind :: Io ( ..) | ErrorKind :: ConnectionPoolClearedError { .. } )
384+ matches ! (
385+ self ,
386+ ErrorKind :: Io ( ..) | ErrorKind :: ConnectionPoolClearedError { .. }
387+ )
377388 }
378389
379390 /// Gets the code/message tuple from this error, if applicable. In the case of write errors, the
@@ -397,13 +408,14 @@ impl ErrorKind {
397408 pub ( crate ) fn code_name ( & self ) -> Option < & str > {
398409 match self {
399410 ErrorKind :: CommandError ( ref cmd_err) => Some ( cmd_err. code_name . as_str ( ) ) ,
400- ErrorKind :: WriteError ( ref failure) => {
401- match failure {
402- WriteFailure :: WriteConcernError ( ref wce) => Some ( wce. code_name . as_str ( ) ) ,
403- WriteFailure :: WriteError ( ref we) => we. code_name . as_deref ( ) ,
404- }
405- }
406- ErrorKind :: BulkWriteError ( ref bwe) => bwe. write_concern_error . as_ref ( ) . map ( |wce| wce. code_name . as_str ( ) ) ,
411+ ErrorKind :: WriteError ( ref failure) => match failure {
412+ WriteFailure :: WriteConcernError ( ref wce) => Some ( wce. code_name . as_str ( ) ) ,
413+ WriteFailure :: WriteError ( ref we) => we. code_name . as_deref ( ) ,
414+ } ,
415+ ErrorKind :: BulkWriteError ( ref bwe) => bwe
416+ . write_concern_error
417+ . as_ref ( )
418+ . map ( |wce| wce. code_name . as_str ( ) ) ,
407419 _ => None ,
408420 }
409421 }
@@ -564,8 +576,8 @@ pub enum WriteFailure {
564576 /// An error that occurred due to not being able to satisfy a write concern.
565577 WriteConcernError ( WriteConcernError ) ,
566578
567- /// An error that occurred during a write operation that wasn't due to being unable to satisfy a
568- /// write concern.
579+ /// An error that occurred during a write operation that wasn't due to being unable to satisfy
580+ /// a write concern.
569581 WriteError ( WriteError ) ,
570582}
571583
0 commit comments