#![no_std]
#![forbid(unsafe_code)]
pub use crc_catalog::algorithm::*;
pub use crc_catalog::{Algorithm, Width};
mod crc128;
mod crc16;
mod crc32;
mod crc64;
mod crc8;
mod table;
mod util;
pub trait Implementation: private::Sealed {
type Data<W>;
}
#[derive(Copy, Clone)]
pub struct Table<const L: usize> {}
pub type NoTable = Table<0>;
type DefaultImpl = Table<1>;
impl<const L: usize> Implementation for Table<L> {
type Data<W> = [[W; 256]; L];
}
mod private {
pub trait Sealed {}
impl<const L: usize> Sealed for super::Table<L> {}
}
#[derive(Clone)]
pub struct Crc<W: Width, I: Implementation = DefaultImpl> {
pub algorithm: &'static Algorithm<W>,
data: I::Data<W>,
}
#[derive(Clone)]
pub struct Digest<'a, W: Width, I: Implementation = DefaultImpl> {
crc: &'a Crc<W, I>,
value: W,
}
#[cfg(test)]
mod test {
use super::{Crc, CRC_32_ISCSI};
#[test]
fn test_clone() {
const CRC: Crc<u32> = Crc::<u32>::new(&CRC_32_ISCSI);
let _crc = CRC.clone();
}
}