pub struct StdPolicy;
Expand description
Default policy for both BufReader
and BufWriter
that reproduces the behaviors of their
std::io
counterparts:
BufReader
: only reads when the buffer is empty, does not resize or move data.BufWriter
: only flushes the buffer when there is not enough room for an incoming write.
Trait Implementations
sourceimpl ReaderPolicy for StdPolicy
impl ReaderPolicy for StdPolicy
Behavior of std::io::BufReader
: the buffer will only be read into if it is empty.
sourcefn before_read(&mut self, buffer: &mut Buffer) -> DoRead
fn before_read(&mut self, buffer: &mut Buffer) -> DoRead
Consulted before attempting to read into the buffer. Read more
sourcefn after_consume(&mut self, _buffer: &mut Buffer, _amt: usize)
fn after_consume(&mut self, _buffer: &mut Buffer, _amt: usize)
Called after bytes are consumed from the buffer. Read more
sourceimpl WriterPolicy for StdPolicy
impl WriterPolicy for StdPolicy
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.
sourcefn before_write(&mut self, buf: &mut Buffer, incoming: usize) -> FlushAmt
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. Read moresourcefn after_write(&mut self, _buf: &Buffer) -> FlushAmt
fn after_write(&mut self, _buf: &Buffer) -> FlushAmt
Return
true
if the buffer should be flushed after reading into it. Read moreAuto Trait Implementations
impl RefUnwindSafe for StdPolicy
impl Send for StdPolicy
impl Sync for StdPolicy
impl Unpin for StdPolicy
impl UnwindSafe for StdPolicy
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more