pub struct WriteBuf<B> { /* private fields */ }
Expand description
Write buffer.
Implementations§
Source§impl<B: AsRef<[u8]> + AsMut<[u8]>> WriteBuf<B>
impl<B: AsRef<[u8]> + AsMut<[u8]>> WriteBuf<B>
Sourcepub fn room(&self) -> usize
pub fn room(&self) -> usize
Returns the free space of the buffer.
Invariant: self.len() + self.room() <= self.capacity()
Sourcepub fn stream_state(&self) -> StreamState
pub fn stream_state(&self) -> StreamState
Returns the state of the stream that operated in the last flush()
call.
Sourcepub fn stream_state_mut(&mut self) -> &mut StreamState
pub fn stream_state_mut(&mut self) -> &mut StreamState
Returns a mutable reference to the StreamState
instance.
Sourcepub fn flush<W: Write>(&mut self, writer: W) -> Result<()>
pub fn flush<W: Write>(&mut self, writer: W) -> Result<()>
Writes the encoded bytes contained in this buffer to the given writer.
The written bytes will be removed from the buffer.
The flush process continues until one of the following condition is satisfied:
- The write buffer became empty
- A write operation returned a
WouldBlock
error - The output stream has reached EOS
Sourcepub fn inner_mut(&mut self) -> &mut B
pub fn inner_mut(&mut self) -> &mut B
Returns a mutable reference to the inner bytes of the buffer.
Sourcepub fn into_inner(self) -> B
pub fn into_inner(self) -> B
Takes ownership of ReadBuf
and returns the inner bytes of the buffer.
Source§impl<B: AsRef<[u8]> + AsMut<[u8]>> WriteBuf<B>
impl<B: AsRef<[u8]> + AsMut<[u8]>> WriteBuf<B>
Sourcepub fn poll_flush<W: AsyncWrite>(
&mut self,
writer: Pin<&mut W>,
cx: &mut Context<'_>,
) -> Poll<Result<()>>
pub fn poll_flush<W: AsyncWrite>( &mut self, writer: Pin<&mut W>, cx: &mut Context<'_>, ) -> Poll<Result<()>>
Writes the encoded bytes contained in this buffer to the given writer.
The written bytes will be removed from the buffer.
The flush process continues until one of the following condition is satisfied:
- The write buffer became empty
- A write operation returned a
WouldBlock
error - The output stream has reached EOS
Trait Implementations§
Source§impl<B: AsRef<[u8]> + AsMut<[u8]>> Write for WriteBuf<B>
impl<B: AsRef<[u8]> + AsMut<[u8]>> Write for WriteBuf<B>
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector
)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored
)