pub fn block2_write<F, R>(
    block2: Block2RequestData,
    response: &mut impl MutableWritableMessage,
    f: F
) -> R
where F: FnOnce(&mut TeeForCrc<'_, '_, u64>) -> R,
Expand description

Provide a writer into the response message

Anything written into the writer is put into the message’s payload, and the Block2 and ETag option of the message are set automatically based on what is written.

As some cleanup is required at the end of the write (eg. setting the ETag and the M flag in the Block2 option), the actual writing needs to take place inside a callback.

Note that only a part of the write (that which was requested by the Block2 operation) is actually persisted; the rest is discarded. When the M flag indicates that the client did not obtain the full message yet, it typically sends another request that is then processed the same way again, for a different “window”.

The type passed in should not be relied on too much – ideally it’d be F: for<W: core::fmt::Write> FnOnce(&mut W) -> R, and the signature may still change in that direction.