1use std::future::Future;
2
3use mm1_address::address::Address;
4use mm1_common::errors::error_of::ErrorOf;
5use mm1_common::impl_error_kind;
6use mm1_proto::message;
7
8use crate::envelope::Envelope;
9
10#[derive(Debug, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
11#[message]
12pub enum RecvErrorKind {
13 Closed,
14}
15
16pub trait Recv: Send {
17 fn address(&self) -> Address;
18
19 fn recv(&mut self) -> impl Future<Output = Result<Envelope, ErrorOf<RecvErrorKind>>> + Send;
20
21 fn close(&mut self) -> impl Future<Output = ()> + Send;
22}
23
24impl_error_kind!(RecvErrorKind);