pub trait RecvStream: Send {
// Required methods
fn recv_bytes(
&mut self,
len: usize,
) -> impl Future<Output = Result<Bytes>> + Send;
fn recv_bytes_exact(
&mut self,
len: usize,
) -> impl Future<Output = Result<Bytes>> + Send;
fn recv<const L: usize>(
&mut self,
) -> impl Future<Output = Result<[u8; L]>> + Send;
fn stop(&mut self, code: VarInt) -> Result<()>;
fn id(&self) -> u64;
}
Expand description
An abstract iroh::endpoint::RecvStream
.
Required Methods§
Sourcefn recv_bytes(
&mut self,
len: usize,
) -> impl Future<Output = Result<Bytes>> + Send
fn recv_bytes( &mut self, len: usize, ) -> impl Future<Output = Result<Bytes>> + Send
Receive up to len
bytes from the stream, directly into a Bytes
.
Sourcefn recv_bytes_exact(
&mut self,
len: usize,
) -> impl Future<Output = Result<Bytes>> + Send
fn recv_bytes_exact( &mut self, len: usize, ) -> impl Future<Output = Result<Bytes>> + Send
Receive exactly len
bytes from the stream, directly into a Bytes
.
This will return an error if the stream ends before len
bytes are read.
Note that this is different from recv_bytes
, which will return fewer bytes if the stream ends.
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.