1010//
1111
1212use crate :: stream_aggregator:: { DtStreamAgg , DtStreamAggChunk } ;
13- use crate :: util:: { Hhmmss , prettybytes} ;
13+ use crate :: util:: { Hhmmss as _ , prettybytes} ;
1414use anyhow as ah;
1515use chrono:: prelude:: * ;
16- use disktest_rawio:: { DEFAULT_SECTOR_SIZE , RawIo , RawIoOsIntf , RawIoResult } ;
16+ use disktest_rawio:: { DEFAULT_SECTOR_SIZE , RawIo , RawIoOsIntf as _ , RawIoResult } ;
1717use movavg:: MovAvg ;
1818use std:: cmp:: min;
1919use std:: path:: { Path , PathBuf } ;
@@ -87,7 +87,7 @@ impl DisktestFile {
8787 // If bytes have been written, try to drop the operating system caches.
8888 if drop_count > 0 {
8989 if let Err ( e) = io. drop_file_caches ( drop_offset, drop_count) {
90- return Err ( ah:: format_err!( "Cache drop error: {}" , e ) ) ;
90+ return Err ( ah:: format_err!( "Cache drop error: {e}" ) ) ;
9191 }
9292 } else {
9393 io. close ( ) ?;
@@ -155,7 +155,7 @@ impl DisktestFile {
155155 }
156156 }
157157
158- /// Get a reference to the PathBuf in use.
158+ /// Get a reference to the ` PathBuf` in use.
159159 fn get_path ( & self ) -> & PathBuf {
160160 & self . path
161161 }
@@ -168,7 +168,7 @@ impl Drop for DisktestFile {
168168 eprintln ! ( "WARNING: File not closed. Closing now..." ) ;
169169 }
170170 if let Err ( e) = self . close ( ) {
171- panic ! ( "Failed to drop operating system caches: {}" , e ) ;
171+ panic ! ( "Failed to drop operating system caches: {e}" ) ;
172172 }
173173 }
174174 }
@@ -188,7 +188,7 @@ pub struct Disktest {
188188}
189189
190190impl Disktest {
191- /// Unlimited max_bytes.
191+ /// Unlimited ` max_bytes` .
192192 pub const UNLIMITED : u64 = u64:: MAX ;
193193
194194 /// Create a new Disktest instance.
@@ -199,14 +199,14 @@ impl Disktest {
199199 /// that is written to disk.
200200 /// If unsure, use `Default::default()`.
201201 /// - seed: The seed for the random data stream generator.
202- /// - round_id: The disk test round. Every round gets a unique data stream.
202+ /// - ` round_id` : The disk test round. Every round gets a unique data stream.
203203 /// If unsure, use `0` (first round).
204- /// - invert_pattern: Bitwise invert the random data stream.
204+ /// - ` invert_pattern` : Bitwise invert the random data stream.
205205 /// If unsure, use `false` (don't invert).
206- /// - nr_threads: The number of threads to spawn when generating the random data stream.
206+ /// - ` nr_threads` : The number of threads to spawn when generating the random data stream.
207207 /// The special value `0` means: Use all CPUs available in the system.
208208 /// If unsure, use `1` (One CPU).
209- /// - quiet_level: The console verbosity of the Disktest code. See [DisktestQuiet].
209+ /// - ` quiet_level` : The console verbosity of the Disktest code. See [` DisktestQuiet` ].
210210 /// - abort: If this optional flag is set to `true` (e.g. by another thread) the Disktest
211211 /// process will abort as soon as possible.
212212 /// If unsure, use `None`.
@@ -402,7 +402,7 @@ impl Disktest {
402402 println ! ( "Writing stopped. Syncing..." ) ;
403403 }
404404 if let Err ( e) = file. sync ( ) {
405- return Err ( ah:: format_err!( "Sync failed: {}" , e ) ) ;
405+ return Err ( ah:: format_err!( "Sync failed: {e}" ) ) ;
406406 }
407407
408408 self . log (
@@ -414,8 +414,7 @@ impl Disktest {
414414
415415 if let Err ( e) = file. close ( ) {
416416 return Err ( ah:: format_err!(
417- "Failed to drop operating system caches: {}" ,
418- e
417+ "Failed to drop operating system caches: {e}"
419418 ) ) ;
420419 }
421420 if success && self . quiet_level < DisktestQuiet :: NoInfo {
@@ -429,7 +428,7 @@ impl Disktest {
429428 pub fn write ( & mut self , file : DisktestFile , seek : u64 , max_bytes : u64 ) -> ah:: Result < u64 > {
430429 let mut file = file;
431430 let mut bytes_left = max_bytes;
432- let mut bytes_written = 0u64 ;
431+ let mut bytes_written = 0_u64 ;
433432
434433 let write_chunk_size = self . init ( & mut file, "Writing" , seek, max_bytes) ?;
435434 loop {
@@ -490,7 +489,7 @@ impl Disktest {
490489 true ,
491490 ) ;
492491 if let Err ( e) = file. close ( ) {
493- return Err ( ah:: format_err!( "Failed to close device: {}" , e ) ) ;
492+ return Err ( ah:: format_err!( "Failed to close device: {e}" ) ) ;
494493 }
495494 Ok ( ( ) )
496495 }
@@ -506,7 +505,7 @@ impl Disktest {
506505 ) -> ah:: Error {
507506 if let Err ( e) = self . verify_finalize ( file, false , bytes_read) {
508507 if self . quiet_level < DisktestQuiet :: NoWarn {
509- eprintln ! ( "{}" , e ) ;
508+ eprintln ! ( "{e}" ) ;
510509 }
511510 }
512511 for ( i, buffer_byte) in buffer. iter ( ) . enumerate ( ) . take ( read_count) {
@@ -517,9 +516,8 @@ impl Disktest {
517516 "Data MISMATCH at {}!" ,
518517 prettybytes( pos, true , true , true )
519518 ) ;
520- } else {
521- return ah:: format_err!( "Data MISMATCH at byte {}!" , pos) ;
522519 }
520+ return ah:: format_err!( "Data MISMATCH at byte {pos}!" ) ;
523521 }
524522 }
525523 panic ! ( "Internal error: verify_failed() no mismatch." ) ;
@@ -529,7 +527,7 @@ impl Disktest {
529527 pub fn verify ( & mut self , file : DisktestFile , seek : u64 , max_bytes : u64 ) -> ah:: Result < u64 > {
530528 let mut file = file;
531529 let mut bytes_left = max_bytes;
532- let mut bytes_read = 0u64 ;
530+ let mut bytes_read = 0_u64 ;
533531
534532 let readbuf_len = self . init ( & mut file, "Verifying" , seek, max_bytes) ? as usize ;
535533 let mut buffer = vec ! [ 0 ; readbuf_len] ;
@@ -580,7 +578,7 @@ impl Disktest {
580578 e
581579 ) ) ;
582580 }
583- } ;
581+ }
584582
585583 if self . abort_requested ( ) {
586584 let _ = self . verify_finalize ( & mut file, false , bytes_read) ;
@@ -597,7 +595,7 @@ mod tests {
597595 use super :: * ;
598596 use crate :: generator:: { GeneratorChaCha8 , GeneratorChaCha12 , GeneratorChaCha20 , GeneratorCrc } ;
599597 use std:: fs:: OpenOptions ;
600- use std:: io:: { Seek , SeekFrom , Write } ;
598+ use std:: io:: { Seek as _ , SeekFrom , Write as _ } ;
601599 use std:: path:: PathBuf ;
602600 use tempfile:: tempdir;
603601
@@ -620,7 +618,7 @@ mod tests {
620618
621619 let mk_filepath = |num| {
622620 let mut path = PathBuf :: from ( tdir_path) ;
623- path. push ( format ! ( "tmp-{}.img" , num ) ) ;
621+ path. push ( format ! ( "tmp-{num }.img" ) ) ;
624622 path
625623 } ;
626624
0 commit comments