pub trait ReadableStream: Send {
// Required methods
fn read_into(
&mut self,
buffer: &mut [u8],
cancellation: &Cancellation,
) -> impl Future<Output = OperationResult<usize>> + Send;
fn try_read_into(&mut self, buffer: &mut [u8]) -> Result<usize>;
fn close(&mut self) -> impl Future<Output = Result<()>> + Send;
}Expand description
A sequential input direction. A nonempty read returns zero at EOF. Independent input and output directions must be able to make progress.
Required Methods§
Sourcefn read_into(
&mut self,
buffer: &mut [u8],
cancellation: &Cancellation,
) -> impl Future<Output = OperationResult<usize>> + Send
fn read_into( &mut self, buffer: &mut [u8], cancellation: &Cancellation, ) -> impl Future<Output = OperationResult<usize>> + Send
Read a possibly short prefix. Empty storage does not establish EOF.
Sourcefn try_read_into(&mut self, buffer: &mut [u8]) -> Result<usize>
fn try_read_into(&mut self, buffer: &mut [u8]) -> Result<usize>
Attempt one read now, without waiting. Unlike polling read_into once, this reaches the transport, so it observes input, EOF and errors already queued there. WouldBlock means no input is available now; zero with nonempty storage is EOF, and empty storage returns zero. Other errors are as for read_into, except that a cancelled transport reports ConnectionAborted, since there is no operation cancellation to report and the input cannot resume. Wrappers must forward this rather than polling a read.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".