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
38
39
40
41
42
43
44
45
46
47
48
#[allow(clippy::module_inception)]
mod client;
mod connector;
use crate::{error::ConnectionError, frame};
pub use self::client::{Client, ClientConnection};
pub use self::connector::Connector;
#[derive(thiserror::Error, Debug)]
pub enum ClientError {
#[error("Protocol error: {0}")]
Protocol(Box<ConnectionError>),
#[error("Http/2 codec error: {0}")]
Frame(#[from] frame::FrameError),
#[error("Handshake timeout")]
HandshakeTimeout,
#[error("Connect error: {0}")]
Connect(Box<ntex_connect::ConnectError>),
#[error("Peer disconnected err: {0:?}")]
Disconnected(Option<std::io::Error>),
}
impl From<ConnectionError> for ClientError {
fn from(err: ConnectionError) -> Self {
Self::Protocol(Box::new(err))
}
}
impl From<std::io::Error> for ClientError {
fn from(err: std::io::Error) -> Self {
Self::Disconnected(Some(err))
}
}
impl From<ntex_connect::ConnectError> for ClientError {
fn from(err: ntex_connect::ConnectError) -> Self {
Self::Connect(Box::new(err))
}
}