From 1ce0602ed9e16eea5035a609fc9710ce25ba857f Mon Sep 17 00:00:00 2001 From: Salman Abuhaimed Date: Sun, 31 Mar 2024 16:03:24 +0300 Subject: [PATCH] expose lookup tables --- src/crc128/bytewise.rs | 6 +++++- src/crc128/default.rs | 4 ++++ src/crc128/slice16.rs | 6 +++++- src/crc16/bytewise.rs | 6 +++++- src/crc16/default.rs | 4 ++++ src/crc16/slice16.rs | 6 +++++- src/crc32/bytewise.rs | 6 +++++- src/crc32/default.rs | 4 ++++ src/crc32/slice16.rs | 6 +++++- src/crc64/bytewise.rs | 6 +++++- src/crc64/default.rs | 4 ++++ src/crc64/slice16.rs | 6 +++++- src/crc8/bytewise.rs | 6 +++++- src/crc8/default.rs | 4 ++++ src/crc8/slice16.rs | 6 +++++- 15 files changed, 70 insertions(+), 10 deletions(-) diff --git a/src/crc128/bytewise.rs b/src/crc128/bytewise.rs index 500d7ea..9e1aac7 100644 --- a/src/crc128/bytewise.rs +++ b/src/crc128/bytewise.rs @@ -1,5 +1,5 @@ use crate::table::crc128_table; -use crate::{Algorithm, Bytewise, Crc, Digest}; +use crate::{Algorithm, Bytewise, Crc, Digest, Implementation}; use super::{finalize, init, update_bytewise}; @@ -32,6 +32,10 @@ impl Crc> { let value = init(self.algorithm, initial); Digest::new(self, value) } + + pub const fn table(&self) -> as Implementation>::Table { + self.table + } } impl<'a> Digest<'a, Bytewise> { diff --git a/src/crc128/default.rs b/src/crc128/default.rs index d623ac4..3e6f699 100644 --- a/src/crc128/default.rs +++ b/src/crc128/default.rs @@ -109,6 +109,10 @@ impl Crc { let value = init(self.algorithm, initial); Digest::new(self, value) } + + pub const fn table(&self) -> ::Table { + self.table + } } impl<'a> Digest<'a, u128> { diff --git a/src/crc128/slice16.rs b/src/crc128/slice16.rs index 948a70d..f8a2ae1 100644 --- a/src/crc128/slice16.rs +++ b/src/crc128/slice16.rs @@ -1,5 +1,5 @@ use crate::table::crc128_table_slice_16; -use crate::{Algorithm, Crc, Digest, Slice16}; +use crate::{Algorithm, Crc, Digest, Implementation, Slice16}; use super::{finalize, init, update_slice16}; @@ -32,6 +32,10 @@ impl Crc> { let value = init(self.algorithm, initial); Digest::new(self, value) } + + pub const fn table(&self) -> as Implementation>::Table { + self.table + } } impl<'a> Digest<'a, Slice16> { diff --git a/src/crc16/bytewise.rs b/src/crc16/bytewise.rs index 1f042dd..5246956 100644 --- a/src/crc16/bytewise.rs +++ b/src/crc16/bytewise.rs @@ -1,6 +1,6 @@ use crate::crc16::{finalize, init, update_bytewise}; use crate::table::crc16_table; -use crate::{Algorithm, Bytewise, Crc, Digest}; +use crate::{Algorithm, Bytewise, Crc, Digest, Implementation}; impl Crc> { pub const fn new(algorithm: &'static Algorithm) -> Self { @@ -31,6 +31,10 @@ impl Crc> { let value = init(self.algorithm, initial); Digest::new(self, value) } + + pub const fn table(&self) -> as Implementation>::Table { + self.table + } } impl<'a> Digest<'a, Bytewise> { diff --git a/src/crc16/default.rs b/src/crc16/default.rs index 55b72c9..f477815 100644 --- a/src/crc16/default.rs +++ b/src/crc16/default.rs @@ -109,6 +109,10 @@ impl Crc { let value = init(self.algorithm, initial); Digest::new(self, value) } + + pub const fn table(&self) -> ::Table { + self.table + } } impl<'a> Digest<'a, u16> { diff --git a/src/crc16/slice16.rs b/src/crc16/slice16.rs index 781cff4..11b0836 100644 --- a/src/crc16/slice16.rs +++ b/src/crc16/slice16.rs @@ -1,6 +1,6 @@ use crate::crc16::{finalize, init, update_slice16}; use crate::table::crc16_table_slice_16; -use crate::{Algorithm, Crc, Digest, Slice16}; +use crate::{Algorithm, Crc, Digest, Implementation, Slice16}; impl Crc> { pub const fn new(algorithm: &'static Algorithm) -> Self { @@ -31,6 +31,10 @@ impl Crc> { let value = init(self.algorithm, initial); Digest::new(self, value) } + + pub const fn table(&self) -> as Implementation>::Table { + self.table + } } impl<'a> Digest<'a, Slice16> { diff --git a/src/crc32/bytewise.rs b/src/crc32/bytewise.rs index 88c7976..3499e6c 100644 --- a/src/crc32/bytewise.rs +++ b/src/crc32/bytewise.rs @@ -1,5 +1,5 @@ use crate::table::crc32_table; -use crate::{Algorithm, Bytewise, Crc, Digest}; +use crate::{Algorithm, Bytewise, Crc, Digest, Implementation}; use crate::crc32::{finalize, init, update_bytewise}; @@ -32,6 +32,10 @@ impl Crc> { let value = init(self.algorithm, initial); Digest::new(self, value) } + + pub const fn table(&self) -> as Implementation>::Table { + self.table + } } impl<'a> Digest<'a, Bytewise> { diff --git a/src/crc32/default.rs b/src/crc32/default.rs index 0aaedd3..d3c6064 100644 --- a/src/crc32/default.rs +++ b/src/crc32/default.rs @@ -109,6 +109,10 @@ impl Crc { let value = init(self.algorithm, initial); Digest::new(self, value) } + + pub const fn table(&self) -> ::Table { + self.table + } } impl<'a> Digest<'a, u32> { diff --git a/src/crc32/slice16.rs b/src/crc32/slice16.rs index 638becc..5755803 100644 --- a/src/crc32/slice16.rs +++ b/src/crc32/slice16.rs @@ -1,5 +1,5 @@ use crate::table::crc32_table_slice_16; -use crate::{Algorithm, Crc, Digest, Slice16}; +use crate::{Algorithm, Crc, Digest, Implementation, Slice16}; use super::{finalize, init, update_slice16}; @@ -32,6 +32,10 @@ impl Crc> { let value = init(self.algorithm, initial); Digest::new(self, value) } + + pub const fn table(&self) -> as Implementation>::Table { + self.table + } } impl<'a> Digest<'a, Slice16> { diff --git a/src/crc64/bytewise.rs b/src/crc64/bytewise.rs index e4b66c0..3603d03 100644 --- a/src/crc64/bytewise.rs +++ b/src/crc64/bytewise.rs @@ -1,5 +1,5 @@ use crate::table::crc64_table; -use crate::{Algorithm, Bytewise, Crc, Digest}; +use crate::{Algorithm, Bytewise, Crc, Digest, Implementation}; use super::{finalize, init, update_bytewise}; @@ -32,6 +32,10 @@ impl Crc> { let value = init(self.algorithm, initial); Digest::new(self, value) } + + pub const fn table(&self) -> as Implementation>::Table { + self.table + } } impl<'a> Digest<'a, Bytewise> { diff --git a/src/crc64/default.rs b/src/crc64/default.rs index bf41dc8..663de64 100644 --- a/src/crc64/default.rs +++ b/src/crc64/default.rs @@ -109,6 +109,10 @@ impl Crc { let value = init(self.algorithm, initial); Digest::new(self, value) } + + pub const fn table(&self) -> ::Table { + self.table + } } impl<'a> Digest<'a, u64> { diff --git a/src/crc64/slice16.rs b/src/crc64/slice16.rs index 0bd279e..1f31fc0 100644 --- a/src/crc64/slice16.rs +++ b/src/crc64/slice16.rs @@ -1,5 +1,5 @@ use crate::table::crc64_table_slice_16; -use crate::{Algorithm, Crc, Digest, Slice16}; +use crate::{Algorithm, Crc, Digest, Implementation, Slice16}; use super::{finalize, init, update_slice16}; @@ -32,6 +32,10 @@ impl Crc> { let value = init(self.algorithm, initial); Digest::new(self, value) } + + pub const fn table(&self) -> as Implementation>::Table { + self.table + } } impl<'a> Digest<'a, Slice16> { diff --git a/src/crc8/bytewise.rs b/src/crc8/bytewise.rs index 1cae39e..207827d 100644 --- a/src/crc8/bytewise.rs +++ b/src/crc8/bytewise.rs @@ -1,6 +1,6 @@ use crate::crc8::{finalize, init, update_bytewise}; use crate::table::crc8_table; -use crate::{Algorithm, Bytewise, Crc, Digest}; +use crate::{Algorithm, Bytewise, Crc, Digest, Implementation}; impl Crc> { pub const fn new(algorithm: &'static Algorithm) -> Self { @@ -31,6 +31,10 @@ impl Crc> { let value = init(self.algorithm, initial); Digest::new(self, value) } + + pub const fn table(&self) -> as Implementation>::Table { + self.table + } } impl<'a> Digest<'a, Bytewise> { diff --git a/src/crc8/default.rs b/src/crc8/default.rs index 9923b3a..475b562 100644 --- a/src/crc8/default.rs +++ b/src/crc8/default.rs @@ -109,6 +109,10 @@ impl Crc { let value = init(self.algorithm, initial); Digest::new(self, value) } + + pub const fn table(&self) -> ::Table { + self.table + } } impl<'a> Digest<'a, u8> { diff --git a/src/crc8/slice16.rs b/src/crc8/slice16.rs index a63ed84..cc148b1 100644 --- a/src/crc8/slice16.rs +++ b/src/crc8/slice16.rs @@ -1,6 +1,6 @@ use crate::crc8::{finalize, init, update_slice16}; use crate::table::crc8_table_slice_16; -use crate::{Algorithm, Crc, Digest, Slice16}; +use crate::{Algorithm, Crc, Digest, Implementation, Slice16}; impl Crc> { pub const fn new(algorithm: &'static Algorithm) -> Self { @@ -31,6 +31,10 @@ impl Crc> { let value = init(self.algorithm, initial); Digest::new(self, value) } + + pub const fn table(&self) -> as Implementation>::Table { + self.table + } } impl<'a> Digest<'a, Slice16> {