Trait digest::VariableOutput[][src]

pub trait VariableOutput: Sized + Update + Reset {
    const MAX_OUTPUT_SIZE: usize;

    fn new(output_size: usize) -> Result<Self, InvalidOutputSize>;
fn output_size(&self) -> usize;
fn finalize_variable(self, f: impl FnOnce(&[u8]));
fn finalize_variable_reset(&mut self, f: impl FnOnce(&[u8])); fn digest_variable(
        input: impl AsRef<[u8]>,
        output: &mut [u8]
    ) -> Result<(), InvalidOutputSize> { ... }
fn finalize_boxed(self) -> Box<[u8]> { ... }
fn finalize_boxed_reset(&mut self) -> Box<[u8]> { ... } }

Trait for variable output size hash functions.

Associated Constants

const MAX_OUTPUT_SIZE: usize[src]

Maximum size of output hash.

Loading content...

Required methods

fn new(output_size: usize) -> Result<Self, InvalidOutputSize>[src]

Create new hasher instance with the given output size.

It will return Err(InvalidOutputSize) in case if hasher can not return hash of the specified output size.

fn output_size(&self) -> usize[src]

Get output size of the hasher instance provided to the new method

fn finalize_variable(self, f: impl FnOnce(&[u8]))[src]

Retrieve result via closure and consume hasher.

Closure is guaranteed to be called, length of the buffer passed to it will be equal to output_size.

fn finalize_variable_reset(&mut self, f: impl FnOnce(&[u8]))[src]

Retrieve result via closure and reset the hasher state.

Closure is guaranteed to be called, length of the buffer passed to it will be equal to output_size.

Loading content...

Provided methods

fn digest_variable(
    input: impl AsRef<[u8]>,
    output: &mut [u8]
) -> Result<(), InvalidOutputSize>
[src]

Compute hash of data and write it to output.

Length of the output hash is determined by output. If output is bigger than Self::MAX_OUTPUT_SIZE, this method returns InvalidOutputSize.

fn finalize_boxed(self) -> Box<[u8]>[src]

This is supported on crate feature alloc only.

Retrieve result into a boxed slice and consume hasher.

Box<[u8]> is used instead of Vec<u8> to save stack space, since they have size of 2 and 3 words respectively.

fn finalize_boxed_reset(&mut self) -> Box<[u8]>[src]

This is supported on crate feature alloc only.

Retrieve result into a boxed slice and reset hasher state.

Box<[u8]> is used instead of Vec<u8> to save stack space, since they have size of 2 and 3 words respectively.

Loading content...

Implementors

impl<T> VariableOutput for RtVariableCoreWrapper<T> where
    T: VariableOutputCore + UpdateCore
[src]

This is supported on crate feature core-api only.
Loading content...