pub trait Pusher: Send + 'static {
type Error: Error + Send + Sync + Unpin + 'static;
// Required method
fn push(
&mut self,
range: &ProgressEntry,
content: Bytes,
) -> Result<(), (Self::Error, Bytes)>;
// Provided methods
fn flush(&mut self) -> Result<(), Self::Error> { ... }
fn set_listener(&mut self, cb: ProgressListener) { ... }
}Expand description
Abstraction over a data sink that receives pushed byte chunks.
The pusher writes data to its destination and can optionally flush.
Required Associated Types§
Required Methods§
Sourcefn push(
&mut self,
range: &ProgressEntry,
content: Bytes,
) -> Result<(), (Self::Error, Bytes)>
fn push( &mut self, range: &ProgressEntry, content: Bytes, ) -> Result<(), (Self::Error, Bytes)>
Write content covering the given range to the destination.
On success returns Ok(()). On failure returns Err((error, bytes))
where bytes is the (possibly partial) payload that was not written,
so the engine can retry it. Implementors should keep already-written
bytes internally on failure rather than dropping them.
Provided Methods§
Sourcefn flush(&mut self) -> Result<(), Self::Error>
fn flush(&mut self) -> Result<(), Self::Error>
Flush any buffered data to the destination.
The default implementation is a no-op. File-backed pushers use this to
issue fsync / flush on the underlying file.
Sourcefn set_listener(&mut self, cb: ProgressListener)
fn set_listener(&mut self, cb: ProgressListener)
Install a callback that fires whenever a chunk has been successfully pushed to its destination.
The default implementation is a no-op. Leaf sinks override this to store the callback; every wrapper must override this to forward it to its inner pusher, otherwise progress events are silently dropped.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".