commit
3b5b17e7ac
|
@ -1,12 +1,12 @@
|
||||||
[package]
|
[package]
|
||||||
name = "const-crc32"
|
name = "const-crc32-nostd"
|
||||||
version = "1.3.0"
|
version = "1.3.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["Jonathan Strong <jstrong@shipyard.rs>"]
|
authors = ["Jonathan Strong <jstrong@shipyard.rs>"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
description = "A `const fn` implementation of crc32 checksum algorithm"
|
description = "A `const fn` implementation of crc32 checksum algorithm"
|
||||||
repository = "https://git.shipyard.rs/jstrong/const-crc32"
|
repository = "https://git.shipyard.rs/jstrong/const-crc32"
|
||||||
keywords = ["checksum", "crc", "crc32", "const"]
|
keywords = ["checksum", "crc", "crc32", "const", "no_std"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|
|
@ -3,10 +3,12 @@
|
||||||
//! # Examples
|
//! # Examples
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
|
//! use const_crc32_nostd as const_crc32;
|
||||||
//! const BYTES: &[u8] = "The quick brown fox jumps over the lazy dog".as_bytes();
|
//! const BYTES: &[u8] = "The quick brown fox jumps over the lazy dog".as_bytes();
|
||||||
//! const CKSUM: u32 = const_crc32::crc32(BYTES);
|
//! const CKSUM: u32 = const_crc32::crc32(BYTES);
|
||||||
//! assert_eq!(CKSUM, 0x414fa339_u32);
|
//! assert_eq!(CKSUM, 0x414fa339_u32);
|
||||||
//! ```
|
//! ```
|
||||||
|
#![no_std]
|
||||||
|
|
||||||
/// used to generate up a [u32; 256] lookup table in `crc32`. this computes
|
/// used to generate up a [u32; 256] lookup table in `crc32`. this computes
|
||||||
/// the table on demand for a given "index" `i`
|
/// the table on demand for a given "index" `i`
|
||||||
|
@ -57,6 +59,8 @@ pub const fn crc32(buf: &[u8]) -> u32 {
|
||||||
/// Calculating the checksum from several parts of a larger input:
|
/// Calculating the checksum from several parts of a larger input:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
|
/// use const_crc32_nostd as const_crc32;
|
||||||
|
///
|
||||||
/// const BYTES: &[u8] = "The quick brown fox jumps over the lazy dog".as_bytes();
|
/// const BYTES: &[u8] = "The quick brown fox jumps over the lazy dog".as_bytes();
|
||||||
///
|
///
|
||||||
/// let mut cksum = 0u32;
|
/// let mut cksum = 0u32;
|
||||||
|
@ -72,6 +76,8 @@ pub const fn crc32(buf: &[u8]) -> u32 {
|
||||||
/// on what kind of data the bytes represent:
|
/// on what kind of data the bytes represent:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
|
/// use const_crc32_nostd as const_crc32;
|
||||||
|
///
|
||||||
/// const THING_ONE_SEED: u32 = 0xbaaaaaad_u32;
|
/// const THING_ONE_SEED: u32 = 0xbaaaaaad_u32;
|
||||||
/// const THING_TWO_SEED: u32 = 0x2bad2bad_u32;
|
/// const THING_TWO_SEED: u32 = 0x2bad2bad_u32;
|
||||||
///
|
///
|
||||||
|
|
Loading…
Reference in New Issue