pub fn stream_into<O, S, B, E>(
runtime: &Handle,
open: O,
stop: impl Fn() -> bool + Clone + Send + Sync + 'static,
write: impl FnMut(&[u8]) -> Result<()>,
) -> Result<u64, StreamError>Expand description
Run open on runtime and hand each chunk of the stream it answers with to
write on this thread, in order. Returns the bytes written.
open gives the stream and its length, when known. stop is checked between
chunks, and every [STALL_CHECK] while the store is silent; so is whether this
side has stopped listening. Ends in an error, never a short success, when the
open or a chunk fails, write refuses one, stop says so, or the runtime shuts
down mid-transfer; the request is dropped with the stream then. Must not be
called on a runtime worker: it blocks.