Skip to main content

HashBytes

Trait HashBytes 

Source
pub trait HashBytes {
    // Required methods
    fn from_iter<I: Iterator<Item = u8>>(iter: I) -> Self
       where Self: Sized;
    fn max_bits() -> usize;
    fn as_slice(&self) -> &[u8] ;
}
Expand description

Interface for types used for storing hash data.

This is implemented for Vec<u8>, Box<[u8]> and arrays of any size.

Required Methods§

Source

fn from_iter<I: Iterator<Item = u8>>(iter: I) -> Self
where Self: Sized,

Construct this type from an iterator of bytes.

If this type has a finite capacity (i.e. an array) then it can ignore extra data (the hash API will not create a hash larger than this type can contain). Unused capacity must be zeroed.

Source

fn max_bits() -> usize

Return the maximum capacity of this type, in bits.

If this type has an arbitrary/theoretically infinite capacity, return usize::max_value().

Source

fn as_slice(&self) -> &[u8]

Get the hash bytes as a slice.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl HashBytes for Box<[u8]>

Source§

fn from_iter<I: Iterator<Item = u8>>(iter: I) -> Self

Source§

fn max_bits() -> usize

Source§

fn as_slice(&self) -> &[u8]

Source§

impl HashBytes for Vec<u8>

Source§

fn from_iter<I: Iterator<Item = u8>>(iter: I) -> Self

Source§

fn max_bits() -> usize

Source§

fn as_slice(&self) -> &[u8]

Source§

impl<const N: usize> HashBytes for [u8; N]

Source§

fn from_iter<I: Iterator<Item = u8>>(iter: I) -> Self

Source§

fn max_bits() -> usize

Source§

fn as_slice(&self) -> &[u8]

Implementors§