File tree Expand file tree Collapse file tree 1 file changed +27
-2
lines changed Expand file tree Collapse file tree 1 file changed +27
-2
lines changed Original file line number Diff line number Diff line change 1
- //! ## Example
1
+ //! Fast, SIMD-accelerated CRC32 (IEEE) checksum computation.
2
+ //!
3
+ //! ## Usage
4
+ //!
5
+ //! ### Simple usage
6
+ //!
7
+ //! For simple use-cases, you can call the [`hash()`] convenience function to
8
+ //! directly compute the CRC32 checksum for a given byte slice:
9
+ //!
10
+ //! ```rust
11
+ //! let checksum = crc32fast::hash(b"foo bar baz");
12
+ //! ```
13
+ //!
14
+ //! ### Advanced usage
15
+ //!
16
+ //! For use-cases that require more flexibility or performance, for example when
17
+ //! processing large amounts of data, you can create and manipulate a [`Hasher`]:
2
18
//!
3
19
//! ```rust
4
20
//! use crc32fast::Hasher;
15
31
//! - A fast baseline implementation which processes up to 16 bytes per iteration
16
32
//! - An optimized implementation for modern `x86` using `sse` and `pclmulqdq` instructions
17
33
//!
18
- //! Calling the `Hasher::new` constructor at runtime will perform a feature detection to select the most
34
+ //! Calling the [ `Hasher::new`] constructor at runtime will perform a feature detection to select the most
19
35
//! optimal implementation for the current CPU feature set.
20
36
21
37
#![ cfg_attr( not( feature = "std" ) , no_std) ]
@@ -43,6 +59,15 @@ mod combine;
43
59
mod specialized;
44
60
mod table;
45
61
62
+ /// Computes the CRC32 hash of a byte slice.
63
+ ///
64
+ /// Check out [`Hasher`] for more advanced use-cases.
65
+ pub fn hash ( buf : & [ u8 ] ) -> u32 {
66
+ let mut h = Hasher :: new ( ) ;
67
+ h. update ( buf) ;
68
+ h. finalize ( )
69
+ }
70
+
46
71
#[ derive( Clone ) ]
47
72
enum State {
48
73
Baseline ( baseline:: State ) ,
You can’t perform that action at this time.
0 commit comments