1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use async_trait::async_trait;
use tokio::sync::mpsc::Receiver;
use anyhow::Result;
use super::Channel;
pub type TOnRemoteChannelReader = Receiver<Box<dyn Channel>>;
#[async_trait]
pub trait Disconnected: Send {
async fn connect(mut self: Box<Self>) -> Result<Box<dyn Connected>>;
async fn listen(mut self: Box<Self>) -> Result<Box<dyn Connected>>;
}
#[async_trait]
pub trait Connected: Send {
fn on_remote_channel(&mut self) -> Result<TOnRemoteChannelReader>;
fn off_remote_channel(&mut self, data: TOnRemoteChannelReader) -> Result<()>;
async fn channel(&mut self, label: String) -> Result<Box<dyn Channel>>;
async fn disconnect(mut self) -> Result<()>;
}