1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#[cfg(feature = "transport-tcp")]
pub mod tcp;
#[cfg(feature = "transport-wss")]
pub mod websocket;
use crate::message::{IRCMessage, IRCParseError};
use async_trait::async_trait;
use futures::prelude::*;
use futures::stream::FusedStream;
use itertools::Either;
use std::fmt::{Debug, Display};
#[async_trait]
pub trait Transport: Sized + Send + Sync + Debug + 'static {
type ConnectError: Send + Sync + Debug + Display;
type IncomingError: Send + Sync + Debug + Display;
type OutgoingError: Send + Sync + Debug + Display + Clone;
type Incoming: FusedStream<Item = Result<IRCMessage, Either<Self::IncomingError, IRCParseError>>>
+ Unpin
+ Send
+ Sync;
type Outgoing: Sink<IRCMessage, Error = Self::OutgoingError> + Unpin + Send + Sync;
async fn new() -> Result<Self, Self::ConnectError>;
fn split(self) -> (Self::Incoming, Self::Outgoing);
}