Struct fletcher_simd::Fletcher
source · pub struct Fletcher<T: FletcherChecksum> { /* private fields */ }Expand description
A Fletcher checksum object that allows for continuous updates to the checksum.
Examples
use fletcher_simd::Fletcher;
const DATA: &str = "abcdefgh";
let mut fletcher = Fletcher::<u16>::new();
fletcher.update_with_slice(DATA.as_bytes());
assert_eq!(fletcher.value(), 0xF824);The update_with_iter method is also available for use with the
Iterator interface.
use byteorder::{ByteOrder, LittleEndian};
use fletcher_simd::Fletcher128;
const DATA: &str = "abcdefgh";
let mut fletcher = Fletcher128::new();
fletcher.update_with_iter(
DATA.as_bytes()
.chunks(8)
.map(|chunk| LittleEndian::read_u64(chunk)),
);
assert_eq!(fletcher.value(), 0x68676665646362616867666564636261);Implementations
sourceimpl Fletcher<u16>
impl Fletcher<u16>
sourcepub fn with_initial_values(a: u8, b: u8) -> Self
pub fn with_initial_values(a: u8, b: u8) -> Self
Constructs a new Fletcher<T> with specific values.
a will represent the lesser significant bits.
b will represent the more significant bits.
sourcepub fn update_with_slice(&mut self, data: &[u8])
pub fn update_with_slice(&mut self, data: &[u8])
Updates the checksum with a slice of data of type T::BlockType.
sourcepub fn update_with_iter<Iter>(&mut self, elems: Iter)where
Iter: Iterator<Item = u8>,
pub fn update_with_iter<Iter>(&mut self, elems: Iter)where
Iter: Iterator<Item = u8>,
Updates the checksum with an iterator over elements of type T::BlockType.
sourcepub fn update_with_iter_scalar<Iter>(&mut self, elems: Iter)where
Iter: Iterator<Item = u8>,
pub fn update_with_iter_scalar<Iter>(&mut self, elems: Iter)where
Iter: Iterator<Item = u8>,
Updates the checksum with an iterator over elements of type T::BlockType using
a scalar-only implementation.
sourceimpl Fletcher<u32>
impl Fletcher<u32>
sourcepub fn with_initial_values(a: u16, b: u16) -> Self
pub fn with_initial_values(a: u16, b: u16) -> Self
Constructs a new Fletcher<T> with specific values.
a will represent the lesser significant bits.
b will represent the more significant bits.
sourcepub fn update_with_slice(&mut self, data: &[u16])
pub fn update_with_slice(&mut self, data: &[u16])
Updates the checksum with a slice of data of type T::BlockType.
sourcepub fn update_with_iter<Iter>(&mut self, elems: Iter)where
Iter: Iterator<Item = u16>,
pub fn update_with_iter<Iter>(&mut self, elems: Iter)where
Iter: Iterator<Item = u16>,
Updates the checksum with an iterator over elements of type T::BlockType.
sourcepub fn update_with_iter_scalar<Iter>(&mut self, elems: Iter)where
Iter: Iterator<Item = u16>,
pub fn update_with_iter_scalar<Iter>(&mut self, elems: Iter)where
Iter: Iterator<Item = u16>,
Updates the checksum with an iterator over elements of type T::BlockType using
a scalar-only implementation.
sourceimpl Fletcher<u64>
impl Fletcher<u64>
sourcepub fn with_initial_values(a: u32, b: u32) -> Self
pub fn with_initial_values(a: u32, b: u32) -> Self
Constructs a new Fletcher<T> with specific values.
a will represent the lesser significant bits.
b will represent the more significant bits.
sourcepub fn update_with_slice(&mut self, data: &[u32])
pub fn update_with_slice(&mut self, data: &[u32])
Updates the checksum with a slice of data of type T::BlockType.
sourcepub fn update_with_iter<Iter>(&mut self, elems: Iter)where
Iter: Iterator<Item = u32>,
pub fn update_with_iter<Iter>(&mut self, elems: Iter)where
Iter: Iterator<Item = u32>,
Updates the checksum with an iterator over elements of type T::BlockType.
sourcepub fn update_with_iter_scalar<Iter>(&mut self, elems: Iter)where
Iter: Iterator<Item = u32>,
pub fn update_with_iter_scalar<Iter>(&mut self, elems: Iter)where
Iter: Iterator<Item = u32>,
Updates the checksum with an iterator over elements of type T::BlockType using
a scalar-only implementation.
sourceimpl Fletcher<u128>
impl Fletcher<u128>
sourcepub fn with_initial_values(a: u64, b: u64) -> Self
pub fn with_initial_values(a: u64, b: u64) -> Self
Constructs a new Fletcher<T> with specific values.
a will represent the lesser significant bits.
b will represent the more significant bits.
sourcepub fn update_with_slice(&mut self, data: &[u64])
pub fn update_with_slice(&mut self, data: &[u64])
Updates the checksum with a slice of data of type T::BlockType.
sourcepub fn update_with_iter<Iter>(&mut self, elems: Iter)where
Iter: Iterator<Item = u64>,
pub fn update_with_iter<Iter>(&mut self, elems: Iter)where
Iter: Iterator<Item = u64>,
Updates the checksum with an iterator over elements of type T::BlockType.
sourcepub fn update_with_iter_scalar<Iter>(&mut self, elems: Iter)where
Iter: Iterator<Item = u64>,
pub fn update_with_iter_scalar<Iter>(&mut self, elems: Iter)where
Iter: Iterator<Item = u64>,
Updates the checksum with an iterator over elements of type T::BlockType using
a scalar-only implementation.