Skip to main content

BufWriterPusher

Struct BufWriterPusher 

Source
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.

Implementations§

Source§

impl<P: Pusher> BufWriterPusher<P>

Source

pub fn new(inner: P, capacity: usize) -> Self

Build a buffered pusher with the given inner sink and buffer capacity.

Trait Implementations§

Source§

impl<P: Debug> Debug for BufWriterPusher<P>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<P: Pusher> Pusher for BufWriterPusher<P>

Source§

type Error = <P as Pusher>::Error

Source§

fn set_listener(&mut self, cb: ProgressListener)

Install a callback that fires whenever a chunk has been successfully pushed to its destination. Read more
Source§

fn push( &mut self, range: &ProgressEntry, bytes: Bytes, ) -> Result<(), (Self::Error, Bytes)>

Write content covering the given range to the destination. Read more
Source§

fn flush(&mut self) -> Result<(), Self::Error>

Flush any buffered data to the destination. Read more

Auto Trait Implementations§

§

impl<P> Freeze for BufWriterPusher<P>
where P: Freeze,

§

impl<P> RefUnwindSafe for BufWriterPusher<P>
where P: RefUnwindSafe,

§

impl<P> Send for BufWriterPusher<P>
where P: Send,

§

impl<P> Sync for BufWriterPusher<P>
where P: Sync,

§

impl<P> Unpin for BufWriterPusher<P>
where P: Unpin,

§

impl<P> UnsafeUnpin for BufWriterPusher<P>
where P: UnsafeUnpin,

§

impl<P> UnwindSafe for BufWriterPusher<P>
where P: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.