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.
Trait Implementations
sourceimpl<T: Clone + FletcherChecksum> Clone for Fletcher<T> where
T::BlockType: Clone,
T::BlockType: Clone,
impl<T: Clone + FletcherChecksum> Clone for Fletcher<T> where
T::BlockType: Clone,
T::BlockType: Clone,
sourceimpl<T: Debug + FletcherChecksum> Debug for Fletcher<T> where
T::BlockType: Debug,
T::BlockType: Debug,
impl<T: Debug + FletcherChecksum> Debug for Fletcher<T> where
T::BlockType: Debug,
T::BlockType: Debug,
sourceimpl<T: Default + FletcherChecksum> Default for Fletcher<T> where
T::BlockType: Default,
T::BlockType: Default,
impl<T: Default + FletcherChecksum> Default for Fletcher<T> where
T::BlockType: Default,
T::BlockType: Default,
sourceimpl<T: PartialEq + FletcherChecksum> PartialEq<Fletcher<T>> for Fletcher<T> where
T::BlockType: PartialEq,
T::BlockType: PartialEq,
impl<T: PartialEq + FletcherChecksum> PartialEq<Fletcher<T>> for Fletcher<T> where
T::BlockType: PartialEq,
T::BlockType: PartialEq,
impl<T: Copy + FletcherChecksum> Copy for Fletcher<T> where
T::BlockType: Copy,
T::BlockType: Copy,
impl<T: FletcherChecksum> StructuralPartialEq for Fletcher<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for Fletcher<T> where
<T as FletcherChecksum>::BlockType: RefUnwindSafe,
impl<T> Send for Fletcher<T> where
<T as FletcherChecksum>::BlockType: Send,
impl<T> Sync for Fletcher<T> where
<T as FletcherChecksum>::BlockType: Sync,
impl<T> Unpin for Fletcher<T> where
<T as FletcherChecksum>::BlockType: Unpin,
impl<T> UnwindSafe for Fletcher<T> where
<T as FletcherChecksum>::BlockType: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more