pub trait ReadHalf: Debug {
// Required method
fn read(&mut self, buf: &mut [u8]) -> impl Future<Output = Result<usize>>;
}
Expand description
The read half of a socket.
Required Methods§
Sourcefn read(&mut self, buf: &mut [u8]) -> impl Future<Output = Result<usize>>
fn read(&mut self, buf: &mut [u8]) -> impl Future<Output = Result<usize>>
Read from a socket.
On completion, the number of bytes read is returned.
Notes for implementers:
- The future returned by this method must be cancel safe.
- While there is no explicit
Unpin
bound on the future returned by this method, it is expected that it provides the same guarentees asUnpin
would require. The reasonUnpin
is 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.