pub struct BufWriterPusher<P> { /* private fields */ }Expand description
Pusher decorator that provides std::io::BufWriter-style linear write buffering.
Unlike the other buffers in this module (direct, merge, seq), which key
chunks by range.start in a BTreeMap to absorb out-of-order writes, this
decorator mimics the fixed-size, sequential buffer (backed by BytesMut) of
std::io::BufWriter: it coalesces contiguous writes into a single push to
the inner pusher, flushing when the buffer is full or when an incoming chunk is
not contiguous with the buffered run.
This keeps the whole write chain in the Pusher abstraction: any Pusher (for
example a raw file sink such as crate::StdFilePusher) can be
wrapped to gain syscall / inner-call batching without depending on
std::io::BufWriter.
§Position tracking
The decorator derives the logical next-write position as run_start + buf.len()
to detect contiguous vs. seeked writes, exactly like StdFilePusher::write_at. On a
non-contiguous write, the buffered run is flushed first and a new run is started
at the new offset.
§Error semantics
On an inner push failure during flush, the buffered run is retained internally
for retry and the incoming bytes are handed back as Err((e, bytes)) so the
caller can retry them; this mirrors the other decorators in this module, which
keep failed data internally rather than dropping it.