@@ -13,8 +13,8 @@ use windows::{
13
13
Win32 :: System :: SystemInformation :: GetLogicalProcessorInformation ,
14
14
Win32 :: System :: SystemInformation :: GetTickCount64 ,
15
15
Win32 :: System :: SystemInformation :: GlobalMemoryStatusEx ,
16
- Win32 :: System :: SystemInformation :: MEMORYSTATUSEX ,
17
16
Win32 :: System :: SystemInformation :: RelationProcessorCore ,
17
+ Win32 :: System :: SystemInformation :: MEMORYSTATUSEX ,
18
18
Win32 :: System :: WindowsProgramming :: GetUserNameA ,
19
19
} ;
20
20
@@ -302,7 +302,7 @@ impl GeneralReadout for WindowsGeneralReadout {
302
302
struct SYSTEM_LOGICAL_PROCESSOR_INFORMATION {
303
303
mask : usize ,
304
304
relationship : u32 ,
305
- _unused : [ u64 ; 2 ]
305
+ _unused : [ u64 ; 2 ] ,
306
306
}
307
307
308
308
// The required size of the buffer, in bytes
@@ -318,7 +318,7 @@ impl GeneralReadout for WindowsGeneralReadout {
318
318
// Could be 0, or some other bogus size
319
319
if needed_size == 0 || needed_size < struct_size || needed_size % struct_size != 0 {
320
320
return Err ( ReadoutError :: Other (
321
- "Call to \" GetLogicalProcessorInformation\" returned an invalid size." . to_string ( )
321
+ "Call to \" GetLogicalProcessorInformation\" returned an invalid size." . to_string ( ) ,
322
322
) ) ;
323
323
}
324
324
@@ -335,9 +335,9 @@ impl GeneralReadout for WindowsGeneralReadout {
335
335
}
336
336
337
337
// If failed for some reason
338
- if result. as_bool ( ) == false {
338
+ if ! result. as_bool ( ) {
339
339
return Err ( ReadoutError :: Other (
340
- "Call to \" GetLogicalProcessorInformation\" failed." . to_string ( )
340
+ "Call to \" GetLogicalProcessorInformation\" failed." . to_string ( ) ,
341
341
) ) ?;
342
342
}
343
343
@@ -348,14 +348,15 @@ impl GeneralReadout for WindowsGeneralReadout {
348
348
buf. set_len ( count as usize ) ;
349
349
}
350
350
351
- let phys_proc_count = buf. iter ( )
351
+ let phys_proc_count = buf
352
+ . iter ( )
352
353
// Only interested in processor packages (physical processors.)
353
354
. filter ( |proc_info| proc_info. Relationship == RelationProcessorCore )
354
355
. count ( ) ;
355
356
356
- return if phys_proc_count == 0 {
357
+ if phys_proc_count == 0 {
357
358
Err ( ReadoutError :: Other (
358
- "No physical processor cores found." . to_string ( )
359
+ "No physical processor cores found." . to_string ( ) ,
359
360
) ) ?
360
361
} else {
361
362
Ok ( phys_proc_count)
@@ -364,7 +365,8 @@ impl GeneralReadout for WindowsGeneralReadout {
364
365
365
366
fn cpu_cores ( & self ) -> Result < usize , ReadoutError > {
366
367
// Open the registry key containing the CPUs information.
367
- let cpu_info = RegKey :: predef ( HKEY_LOCAL_MACHINE ) . open_subkey ( "HARDWARE\\ DESCRIPTION\\ System\\ CentralProcessor" ) ?;
368
+ let cpu_info = RegKey :: predef ( HKEY_LOCAL_MACHINE )
369
+ . open_subkey ( "HARDWARE\\ DESCRIPTION\\ System\\ CentralProcessor" ) ?;
368
370
// Count the number of subkeys, which is the number of CPU logical processors.
369
371
Ok ( cpu_info. enum_keys ( ) . count ( ) )
370
372
}
0 commit comments