pub trait ReadHalf: Debug {
// Required method
fn read(
&mut self,
buf: &mut [u8],
) -> impl Future<Output = Result<ReadResult>>;
}Expand description
The read half of a socket.
Required Methods§
Sourcefn read(&mut self, buf: &mut [u8]) -> impl Future<Output = Result<ReadResult>>
fn read(&mut self, buf: &mut [u8]) -> impl Future<Output = Result<ReadResult>>
Read from a socket.
On completion, the number of bytes read and any file descriptors received are returned.
Notes for implementers:
- The future returned by this method must be cancel safe.
- While there is no explicit
Unpinbound on the future returned by this method, it is expected that it provides the same guarentees asUnpinwould require. The reasonUnpinis not explicitly requied is that it would force boxing (and therefore allocation) on the implemention that useasync fn, which is undesirable for embedded use cases. See this issue for details.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.