跳到主要内容

Context

特性 Context 

Source
pub trait Context: Send + Sync {
    // Required methods
    fn fork_finish(&self) -> Output;
    fn fork(&self) -> Box<dyn Context>;
    fn finish(self: Box<Self>) -> Output;
    fn update(&mut self, data: &[u8]);
}
展开描述

How 到 incrementally compute 一个 hash.

必需方法§

Source

fn fork_finish(&self) -> Output

Finish the computation, returning the resulting output.

此 computation remains valid, 并 more data can be added later with Context::update()

Compare with Context::finish() which consumes the computation 并 prevents any further data being added. This can be more efficient because it avoids 一个 hash context copy 到 apply Merkle-Damgård padding (if required)。

Source

fn fork(&self) -> Box<dyn Context>

分叉计算,产生另一个信息 same prefix as this one.

Source

fn finish(self: Box<Self>) -> Output

Terminate 并 finish the computation, returning the resulting output.

Further data cannot be added after this, because the context is 已消耗. Compare Context::fork_finish()

Source

fn update(&mut self, data: &[u8])

Add data 到 computation.

实现者§