Skip to content

Commit

Permalink
expose lookup tables
Browse files Browse the repository at this point in the history
  • Loading branch information
BKSalman committed Mar 31, 2024
1 parent 5e38fdd commit 1ce0602
Show file tree
Hide file tree
Showing 15 changed files with 70 additions and 10 deletions.
6 changes: 5 additions & 1 deletion src/crc128/bytewise.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down Expand Up @@ -32,6 +32,10 @@ impl Crc<Bytewise<u128>> {
let value = init(self.algorithm, initial);
Digest::new(self, value)
}

pub const fn table(&self) -> <Bytewise<u128> as Implementation>::Table {
self.table
}
}

impl<'a> Digest<'a, Bytewise<u128>> {
Expand Down
4 changes: 4 additions & 0 deletions src/crc128/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ impl Crc<u128> {
let value = init(self.algorithm, initial);
Digest::new(self, value)
}

pub const fn table(&self) -> <u128 as Implementation>::Table {
self.table
}
}

impl<'a> Digest<'a, u128> {
Expand Down
6 changes: 5 additions & 1 deletion src/crc128/slice16.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down Expand Up @@ -32,6 +32,10 @@ impl Crc<Slice16<u128>> {
let value = init(self.algorithm, initial);
Digest::new(self, value)
}

pub const fn table(&self) -> <Slice16<u128> as Implementation>::Table {
self.table
}
}

impl<'a> Digest<'a, Slice16<u128>> {
Expand Down
6 changes: 5 additions & 1 deletion src/crc16/bytewise.rs
Original file line number Diff line number Diff line change
@@ -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<Bytewise<u16>> {
pub const fn new(algorithm: &'static Algorithm<u16>) -> Self {
Expand Down Expand Up @@ -31,6 +31,10 @@ impl Crc<Bytewise<u16>> {
let value = init(self.algorithm, initial);
Digest::new(self, value)
}

pub const fn table(&self) -> <Bytewise<u16> as Implementation>::Table {
self.table
}
}

impl<'a> Digest<'a, Bytewise<u16>> {
Expand Down
4 changes: 4 additions & 0 deletions src/crc16/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ impl Crc<u16> {
let value = init(self.algorithm, initial);
Digest::new(self, value)
}

pub const fn table(&self) -> <u16 as Implementation>::Table {
self.table
}
}

impl<'a> Digest<'a, u16> {
Expand Down
6 changes: 5 additions & 1 deletion src/crc16/slice16.rs
Original file line number Diff line number Diff line change
@@ -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<Slice16<u16>> {
pub const fn new(algorithm: &'static Algorithm<u16>) -> Self {
Expand Down Expand Up @@ -31,6 +31,10 @@ impl Crc<Slice16<u16>> {
let value = init(self.algorithm, initial);
Digest::new(self, value)
}

pub const fn table(&self) -> <Slice16<u16> as Implementation>::Table {
self.table
}
}

impl<'a> Digest<'a, Slice16<u16>> {
Expand Down
6 changes: 5 additions & 1 deletion src/crc32/bytewise.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down Expand Up @@ -32,6 +32,10 @@ impl Crc<Bytewise<u32>> {
let value = init(self.algorithm, initial);
Digest::new(self, value)
}

pub const fn table(&self) -> <Bytewise<u32> as Implementation>::Table {
self.table
}
}

impl<'a> Digest<'a, Bytewise<u32>> {
Expand Down
4 changes: 4 additions & 0 deletions src/crc32/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ impl Crc<u32> {
let value = init(self.algorithm, initial);
Digest::new(self, value)
}

pub const fn table(&self) -> <u32 as Implementation>::Table {
self.table
}
}

impl<'a> Digest<'a, u32> {
Expand Down
6 changes: 5 additions & 1 deletion src/crc32/slice16.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down Expand Up @@ -32,6 +32,10 @@ impl Crc<Slice16<u32>> {
let value = init(self.algorithm, initial);
Digest::new(self, value)
}

pub const fn table(&self) -> <Slice16<u32> as Implementation>::Table {
self.table
}
}

impl<'a> Digest<'a, Slice16<u32>> {
Expand Down
6 changes: 5 additions & 1 deletion src/crc64/bytewise.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down Expand Up @@ -32,6 +32,10 @@ impl Crc<Bytewise<u64>> {
let value = init(self.algorithm, initial);
Digest::new(self, value)
}

pub const fn table(&self) -> <Bytewise<u64> as Implementation>::Table {
self.table
}
}

impl<'a> Digest<'a, Bytewise<u64>> {
Expand Down
4 changes: 4 additions & 0 deletions src/crc64/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ impl Crc<u64> {
let value = init(self.algorithm, initial);
Digest::new(self, value)
}

pub const fn table(&self) -> <u64 as Implementation>::Table {
self.table
}
}

impl<'a> Digest<'a, u64> {
Expand Down
6 changes: 5 additions & 1 deletion src/crc64/slice16.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down Expand Up @@ -32,6 +32,10 @@ impl Crc<Slice16<u64>> {
let value = init(self.algorithm, initial);
Digest::new(self, value)
}

pub const fn table(&self) -> <Slice16<u64> as Implementation>::Table {
self.table
}
}

impl<'a> Digest<'a, Slice16<u64>> {
Expand Down
6 changes: 5 additions & 1 deletion src/crc8/bytewise.rs
Original file line number Diff line number Diff line change
@@ -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<Bytewise<u8>> {
pub const fn new(algorithm: &'static Algorithm<u8>) -> Self {
Expand Down Expand Up @@ -31,6 +31,10 @@ impl Crc<Bytewise<u8>> {
let value = init(self.algorithm, initial);
Digest::new(self, value)
}

pub const fn table(&self) -> <Bytewise<u8> as Implementation>::Table {
self.table
}
}

impl<'a> Digest<'a, Bytewise<u8>> {
Expand Down
4 changes: 4 additions & 0 deletions src/crc8/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ impl Crc<u8> {
let value = init(self.algorithm, initial);
Digest::new(self, value)
}

pub const fn table(&self) -> <u8 as Implementation>::Table {
self.table
}
}

impl<'a> Digest<'a, u8> {
Expand Down
6 changes: 5 additions & 1 deletion src/crc8/slice16.rs
Original file line number Diff line number Diff line change
@@ -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<Slice16<u8>> {
pub const fn new(algorithm: &'static Algorithm<u8>) -> Self {
Expand Down Expand Up @@ -31,6 +31,10 @@ impl Crc<Slice16<u8>> {
let value = init(self.algorithm, initial);
Digest::new(self, value)
}

pub const fn table(&self) -> <Slice16<u8> as Implementation>::Table {
self.table
}
}

impl<'a> Digest<'a, Slice16<u8>> {
Expand Down

0 comments on commit 1ce0602

Please sign in to comment.