2 use num_enum::TryFromPrimitiveError;
4 use tokio::sync::mpsc::error::SendError;
6 #[derive(Error, Debug)]
8 #[error("io error: {0}")]
9 IoError(#[from] std::io::Error),
10 #[error("invalid protocol ID: {0}")]
12 #[error("invalid channel: {0}")]
14 #[error("invalid type: {0}")]
16 #[error("invalid control type: {0}")]
18 #[error("peer ID already set")]
20 #[error("chunk index {0} bigger than chunk count {1}")]
21 InvalidChunkIndex(usize, usize),
22 #[error("chunk count changed from {0} to {1}")]
23 InvalidChunkCount(usize, usize),
24 #[error("remote disconnected (timeout = {0})")]
26 #[error("local disconnected")]
30 impl From<TryFromPrimitiveError<PktType>> for Error {
31 fn from(err: TryFromPrimitiveError<PktType>) -> Self {
32 Self::InvalidType(err.number)
36 impl From<TryFromPrimitiveError<CtlType>> for Error {
37 fn from(err: TryFromPrimitiveError<CtlType>) -> Self {
38 Self::InvalidCtlType(err.number)
42 impl From<SendError<InPkt>> for Error {
43 fn from(_err: SendError<InPkt>) -> Self {