File tree Expand file tree Collapse file tree 2 files changed +13
-39
lines changed Expand file tree Collapse file tree 2 files changed +13
-39
lines changed Original file line number Diff line number Diff line change 7
7
8
8
#![ cfg( any( target_arch = "aarch64" , target_arch = "x86_64" , target_arch = "x86" ) ) ]
9
9
10
+ use crate :: structs:: CrcParams ;
10
11
use crate :: CrcAlgorithm ;
11
12
use crate :: { get_calculator_target, Digest } ;
12
13
use std:: ffi:: CStr ;
13
14
use std:: os:: raw:: c_char;
14
15
use std:: slice;
15
- use crate :: structs:: CrcParams ;
16
16
17
17
/// A handle to the Digest object
18
18
#[ repr( C ) ]
@@ -111,7 +111,9 @@ pub extern "C" fn crc_fast_digest_new(algorithm: CrcFastAlgorithm) -> *mut CrcFa
111
111
112
112
/// Creates a new Digest to compute CRC checksums using custom parameters
113
113
#[ no_mangle]
114
- pub extern "C" fn crc_fast_digest_new_with_params ( params : CrcFastParams ) -> * mut CrcFastDigestHandle {
114
+ pub extern "C" fn crc_fast_digest_new_with_params (
115
+ params : CrcFastParams ,
116
+ ) -> * mut CrcFastDigestHandle {
115
117
let digest = Box :: new ( Digest :: new_with_params ( params. into ( ) ) ) ;
116
118
let handle = Box :: new ( CrcFastDigestHandle ( Box :: into_raw ( digest) ) ) ;
117
119
Box :: into_raw ( handle)
@@ -293,7 +295,7 @@ pub extern "C" fn crc_fast_checksum_file_with_params(
293
295
& convert_to_string ( path_ptr, path_len) ,
294
296
None ,
295
297
)
296
- . unwrap_or ( 0 ) // Return 0 on error instead of panicking
298
+ . unwrap_or ( 0 ) // Return 0 on error instead of panicking
297
299
}
298
300
}
299
301
Original file line number Diff line number Diff line change @@ -623,22 +623,13 @@ mod lib {
623
623
#[ test]
624
624
fn test_digest_updates_check_with_custom_params ( ) {
625
625
// CRC-32 reflected
626
- check_digest (
627
- Digest :: new_with_params ( CRC32_ISCSI ) ,
628
- CRC32_ISCSI . check ,
629
- ) ;
626
+ check_digest ( Digest :: new_with_params ( CRC32_ISCSI ) , CRC32_ISCSI . check ) ;
630
627
631
628
// CRC-32 forward
632
- check_digest (
633
- Digest :: new_with_params ( CRC32_BZIP2 ) ,
634
- CRC32_BZIP2 . check ,
635
- ) ;
629
+ check_digest ( Digest :: new_with_params ( CRC32_BZIP2 ) , CRC32_BZIP2 . check ) ;
636
630
637
631
// CRC-64 reflected
638
- check_digest (
639
- Digest :: new_with_params ( CRC64_NVME ) ,
640
- CRC64_NVME . check ,
641
- ) ;
632
+ check_digest ( Digest :: new_with_params ( CRC64_NVME ) , CRC64_NVME . check ) ;
642
633
643
634
// CRC-64 forward
644
635
check_digest (
@@ -651,10 +642,7 @@ mod lib {
651
642
digest. update ( b"123" ) ;
652
643
digest. update ( b"456" ) ;
653
644
digest. update ( b"789" ) ;
654
- assert_eq ! (
655
- digest. finalize( ) ,
656
- check,
657
- ) ;
645
+ assert_eq ! ( digest. finalize( ) , check, ) ;
658
646
}
659
647
660
648
#[ test]
@@ -762,32 +750,16 @@ mod lib {
762
750
}
763
751
764
752
// CRC-32 reflected
765
- check_file (
766
- CRC32_ISCSI ,
767
- test_file_path,
768
- CRC32_ISCSI . check ,
769
- ) ;
753
+ check_file ( CRC32_ISCSI , test_file_path, CRC32_ISCSI . check ) ;
770
754
771
755
// CRC-32 forward
772
- check_file (
773
- CRC32_BZIP2 ,
774
- test_file_path,
775
- CRC32_BZIP2 . check ,
776
- ) ;
756
+ check_file ( CRC32_BZIP2 , test_file_path, CRC32_BZIP2 . check ) ;
777
757
778
758
// CRC-64 reflected
779
- check_file (
780
- CRC64_NVME ,
781
- test_file_path,
782
- CRC64_NVME . check ,
783
- ) ;
759
+ check_file ( CRC64_NVME , test_file_path, CRC64_NVME . check ) ;
784
760
785
761
// CRC-64 forward
786
- check_file (
787
- CRC64_ECMA_182 ,
788
- test_file_path,
789
- CRC64_ECMA_182 . check ,
790
- ) ;
762
+ check_file ( CRC64_ECMA_182 , test_file_path, CRC64_ECMA_182 . check ) ;
791
763
792
764
std:: fs:: remove_file ( test_file_path) . unwrap ( ) ;
793
765
}
You can’t perform that action at this time.
0 commit comments