async_compression/tokio/write/
buf_write.rs

1use std::{
2    io,
3    pin::Pin,
4    task::{Context, Poll},
5};
6
7pub(crate) trait AsyncBufWrite {
8    /// Attempt to return an internal buffer to write to, flushing data out to the inner reader if
9    /// it is full.
10    ///
11    /// On success, returns `Poll::Ready(Ok(buf))`.
12    ///
13    /// If the buffer is full and cannot be flushed, the method returns `Poll::Pending` and
14    /// arranges for the current task context (`cx`) to receive a notification when the object
15    /// becomes readable or is closed.
16    fn poll_partial_flush_buf(
17        self: Pin<&mut Self>,
18        cx: &mut Context<'_>,
19    ) -> Poll<io::Result<&mut [u8]>>;
20
21    /// Tells this buffer that `amt` bytes have been written to its buffer, so they should be
22    /// written out to the underlying IO when possible.
23    ///
24    /// This function is a lower-level call. It needs to be paired with the `poll_flush_buf` method to
25    /// function properly. This function does not perform any I/O, it simply informs this object
26    /// that some amount of its buffer, returned from `poll_flush_buf`, has been written to and should
27    /// be sent. As such, this function may do odd things if `poll_flush_buf` isn't
28    /// called before calling it.
29    ///
30    /// The `amt` must be `<=` the number of bytes in the buffer returned by `poll_flush_buf`.
31    fn produce(self: Pin<&mut Self>, amt: usize);
32}