pub trait CollapsibleReadWriteIoBuffer: ReadWriteIoBuffer {
// Required method
fn collapse(&mut self);
}
Expand description
An I/O buffer that can be “collapsed” to regain unused capacity.
Required Methods§
Sourcefn collapse(&mut self)
fn collapse(&mut self)
Collapses the buffer, shifting any remaining data to the beginning of the buffer.
This allows for more efficient use of the buffer, as remaining chunks that have yet to be read can be shifted to the left to allow for subsequent reads to take place in the remaining capacity. This is particularly useful for dealing with framed protocols, where multiple payloads may be present in a single buffer, and partial reads need to be completed in order to extract the next frame.