pub struct Stream<'env, D> { /* private fields */ }Expand description
The messages of one stream call, and the places for their digests,
borrowed for its scope; D is the stream’s handler.
Implementations§
Source§impl<'env, D: FnMut(&'env mut [Hash])> Stream<'env, D>
impl<'env, D: FnMut(&'env mut [Hash])> Stream<'env, D>
Sourcepub fn submit(&mut self, message: &'env [u8], out: &'env mut Hash)
pub fn submit(&mut self, message: &'env [u8], out: &'env mut Hash)
Hash message where it is, its digest into out.
Sourcepub fn submit_with(
&mut self,
len: usize,
fill: impl FnMut(usize, &mut [u8]),
out: &'env mut Hash,
)
pub fn submit_with( &mut self, len: usize, fill: impl FnMut(usize, &mut [u8]), out: &'env mut Hash, )
Hash a message of len bytes that fill writes in place, into the
stream’s own bytes, in pieces of up to 64 KiB, its digest into
out: fill(at, room) writes the message’s bytes from at into
all of room (a read from a file or socket straight into the
stream). Each room starts on a 64-byte boundary. The stream
reuses the bytes once out is handed back; a stream keeps 2 MiB of
them, and submit_with waits for room as submit does.
Sourcepub fn submit_reader(
&mut self,
reader: impl Read,
size_hint: Option<u64>,
out: &'env mut Hash,
) -> Result<u64>
pub fn submit_reader( &mut self, reader: impl Read, size_hint: Option<u64>, out: &'env mut Hash, ) -> Result<u64>
Hash the message reader yields, to its end, read straight into the
stream’s own bytes in pieces of up to 64 KiB (a file or socket read
into the stream, overlapping the hashing of earlier pieces), its
digest into out: the message’s length on success. On a read error
(other than an interruption, which reads again) the error returns,
out gets no digest and is not handed back, and the stream goes on
with the next message. The length need not be known: the stream
reads one piece ahead to tell the last.
size_hint is the length the caller expects, where it knows one (a
file’s size, a protocol’s length field): a scheduling hint, never
part of the hash, so a wrong one costs nothing but speed. Today the
stream does not use it; it is here so that a stream that schedules
by it later changes no caller.
Sourcepub fn submit_batch(
&mut self,
batch: &'env [u8],
message_len: usize,
out: &'env mut [Hash],
)
pub fn submit_batch( &mut self, batch: &'env [u8], message_len: usize, out: &'env mut [Hash], )
Hash a batch of messages of message_len bytes where it is, laid
out as hash_many takes them (each in whole
blocks, zero after its bytes), a digest per message into out, in
the messages’ order: out holds one per message. The batch goes in
parts of up to 64 KiB, each one entry; out comes back whole.
Sourcepub fn submit_batch_with(
&mut self,
message_len: usize,
fill: impl FnMut(usize, &mut [u8]),
out: &'env mut [Hash],
)
pub fn submit_batch_with( &mut self, message_len: usize, fill: impl FnMut(usize, &mut [u8]), out: &'env mut [Hash], )
Hash a batch of out.len() messages of message_len bytes that
fill writes in place, laid out as hash_many
takes them: fill(at, room) writes the batch’s bytes from at
(padding included: each message in whole blocks, zero after its
bytes) into all of room, a part of up to 64 KiB at a time. As
submit_with and submit_batch.