|
|
|
@ -17,11 +17,17 @@ use bytes::{
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
|
pub struct Buffered<T: ?Sized, const SIZE: usize>
|
|
|
|
|
{
|
|
|
|
|
/// When an I/O error is hit when reading /writing into/from the internal buffer, store it here if there is data to dump from it.
|
|
|
|
|
/// When there is no more data to return, return this error and then set `poisoned` to true.
|
|
|
|
|
///
|
|
|
|
|
/// After that, all calls to `poll_read()`/`poll_write()` will return a new error indicating the stream has faulted.
|
|
|
|
|
error: Option<io::Error>,
|
|
|
|
|
/// If an error has been set above and/or released from the above slot, set this to true.
|
|
|
|
|
/// Then all subsequent reads or writes will return a new error.
|
|
|
|
|
poisoned: bool,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Current internal buffer
|
|
|
|
|
/// When it's full to `SIZE`, it should be written to `stream` at once then cleared when it's been written.
|
|
|
|
|
buffer: SmallVec<[u8; SIZE]>, //TODO: Can we have a non-spilling stack vec?
|
|
|
|
|
#[pin] stream: T
|
|
|
|
|
}
|
|
|
|
|