Skip to content

Commit

Permalink
expose lookup tables
Browse files Browse the repository at this point in the history
  • Loading branch information
BKSalman committed Apr 2, 2024
1 parent f336f1e commit 97f3190
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/crc128/bytewise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ impl Crc<u128, Table<1>> {
let value = init(self.algorithm, initial);
Digest::new(self, value)
}

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

impl<'a> Digest<'a, u128, Table<1>> {
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, Table};
use crate::*;

use super::{finalize, init, update_slice16};

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

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

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

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

impl<'a> Digest<'a, u16, Table<1>> {
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, Table};
use crate::*;

impl Crc<u16, Table<16>> {
pub const fn new(algorithm: &'static Algorithm<u16>) -> Self {
Expand Down Expand Up @@ -31,6 +31,10 @@ impl Crc<u16, Table<16>> {
let value = init(self.algorithm, initial);
Digest::new(self, value)
}

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

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

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

impl<'a> Digest<'a, u32, Table<1>> {
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, Table};
use crate::*;

use super::{finalize, init, update_slice16};

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

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

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

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

impl<'a> Digest<'a, u64, Table<1>> {
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, Table};
use crate::*;

use super::{finalize, init, update_slice16};

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

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

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

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

impl<'a> Digest<'a, u8, Table<1>> {
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, Table};
use crate::*;

impl Crc<u8, Table<16>> {
pub const fn new(algorithm: &'static Algorithm<u8>) -> Self {
Expand Down Expand Up @@ -31,6 +31,10 @@ impl Crc<u8, Table<16>> {
let value = init(self.algorithm, initial);
Digest::new(self, value)
}

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

impl<'a> Digest<'a, u8, Table<16>> {
Expand Down

0 comments on commit 97f3190

Please sign in to comment.