pub struct BufInsertFormatted { /* private fields */ }Expand description
A wrapper around InsertFormatted which buffers writes.
Implementations§
Source§impl BufInsertFormatted
impl BufInsertFormatted
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Return the current capacity of the buffer.
Note: Size is Not Constant This may be smaller than the original capacity if part of the buffer is still being used by the connection.
This may be larger if a call to Self::write_buffered() caused the buffer to expand.
Sourcepub fn write_buffered(&mut self, data: &[u8])
pub fn write_buffered(&mut self, data: &[u8])
Write data to the buffer without waiting for it to be flushed.
May cause the buffer to resize to fit the data.
Sourcepub async fn write(&mut self, data: &[u8]) -> Result<usize>
pub async fn write(&mut self, data: &[u8]) -> Result<usize>
Write some data to the buffer, flushing first if it is already full.
Returns the number of bytes written, which may be less than data.len() if the remaining
capacity was smaller.
Cancel-safe. Until this returns Ok(n), the contents of data are not yet written to the
buffer.
Sourcepub async fn flush(&mut self) -> Result<()>
pub async fn flush(&mut self) -> Result<()>
Flush the buffer to the server as a single chunk.
If compression is enabled, the full buffer will be compressed.
Sourcepub async fn end(&mut self) -> Result<()>
pub async fn end(&mut self) -> Result<()>
Flushes the buffer, then calls InsertFormatted::end().
Cancel-safe.
Trait Implementations§
Source§impl AsyncWrite for BufInsertFormatted
impl AsyncWrite for BufInsertFormatted
Source§fn poll_write(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<Result<usize, Error>>
fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize, Error>>
buf into the object. Read moreSource§fn poll_flush(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<(), Error>>
fn poll_flush( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Result<(), Error>>
Source§fn poll_shutdown(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<(), Error>>
fn poll_shutdown( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Result<(), Error>>
Source§fn poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>],
) -> Poll<Result<usize, Error>>
fn poll_write_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>], ) -> Poll<Result<usize, Error>>
poll_write, except that it writes from a slice of buffers. Read moreSource§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
poll_write_vectored
implementation. Read more