Trait buf_redux::policy::WriterPolicy [−][src]
pub trait WriterPolicy { fn before_write(&mut self, buf: &mut Buffer, incoming: usize) -> FlushAmt { ... } fn after_write(&mut self, _buf: &Buffer) -> FlushAmt { ... } }
A trait which tells BufWriter
when to flush.
Provided Methods
fn before_write(&mut self, buf: &mut Buffer, incoming: usize) -> FlushAmt
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.
fn after_write(&mut self, _buf: &Buffer) -> FlushAmt
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
impl WriterPolicy for StdPolicy
impl WriterPolicy for FlushAtLeast
impl WriterPolicy for FlushExact
impl WriterPolicy for FlushOn
impl WriterPolicy for FlushOnNewline