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]);
}
Expand description
How to incrementally compute a hash.
Required Methods§
Sourcefn fork_finish(&self) -> Output
fn fork_finish(&self) -> Output
Finish the computation, returning the resulting output.
The computation remains valid, and more data can be added later with
Context::update()
.
Compare with Context::finish()
which consumes the computation
and prevents any further data being added. This can be more efficient
because it avoids a hash context copy to apply Merkle-Damgård padding
(if required).
Sourcefn fork(&self) -> Box<dyn Context>
fn fork(&self) -> Box<dyn Context>
Fork the computation, producing another context that has the same prefix as this one.
Sourcefn finish(self: Box<Self>) -> Output
fn finish(self: Box<Self>) -> Output
Terminate and finish the computation, returning the resulting output.
Further data cannot be added after this, because the context is consumed.
Compare Context::fork_finish()
.