Skip to main content

compio_io/read/
multi.rs

1use futures_util::Stream;
2
3use crate::{AsyncReadManaged, AsyncReadManagedAt, IoResult};
4
5/// # AsyncReadMulti
6///
7/// Async read with buffer pool and returns a stream of managed buffers.
8pub trait AsyncReadMulti: AsyncReadManaged {
9    /// Read some bytes from this source and return a stream of
10    /// [`AsyncReadManaged::Buffer`].
11    ///
12    /// # Implementation Note
13    ///
14    /// - If `len` == 0, implementation should use buffer's size as `len`
15    /// - if `len` > 0, `min(len, buffer_size)` will be the max number of bytes
16    ///   to be read each time.
17    fn read_multi(&mut self, len: usize) -> impl Stream<Item = IoResult<Self::Buffer>>;
18}
19
20/// # AsyncReadMultiAt
21///
22/// Async read with buffer pool and position, returns a stream of managed
23/// buffers.
24pub trait AsyncReadMultiAt: AsyncReadManagedAt {
25    /// Read some bytes from this source at position and return a stream of
26    /// [`AsyncReadManagedAt::Buffer`].
27    ///
28    /// # Implementation Note
29    ///
30    /// - If `len` == 0, implementation should use buffer's size as `len`
31    /// - if `len` > 0, `min(len, buffer_size)` will be the max number of bytes
32    ///   to be read each time.
33    fn read_multi_at(&self, len: usize, pos: u64) -> impl Stream<Item = IoResult<Self::Buffer>>;
34}