pub trait WriterPolicy {
    fn before_write(&mut self, buf: &mut Buffer, incoming: usize) -> FlushAmt { ... }
    fn after_write(&mut self, _buf: &Buffer) -> FlushAmt { ... }
}
Expand description

A trait which tells BufWriter when to flush.

Provided Methods

Return FlushAmt(n > 0) if the buffer should be flushed before reading into it. If the returned amount is 0 or greater than the amount of buffered data, no flush is performed.

The buffer is provided, as well as incoming which is the size of the buffer that will be written to the BufWriter.

By default, flushes the buffer if the usable space is smaller than the incoming write.

Return true if the buffer should be flushed after reading into it.

buf references the updated buffer after the read.

Default impl is a no-op.

Implementors

Default behavior of std::io::BufWriter: flush before a read into the buffer only if the incoming data is larger than the buffer’s writable space.