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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
use std::io;
use thiserror::Error;
#[derive(Error, Debug, Clone)]
pub enum TcpTargetError {
#[error("I/O error: {0}")]
Io(String),
#[error("Serialization error: {0}")]
Serialization(String),
#[error("Cryptographic error: {0}")]
Crypto(String),
#[error("Protocol error: {0}")]
Protocol(String),
#[error("Authentication failed: {0}")]
Authentication(String),
#[error("File operation error: {0}")]
File(String),
#[error("Network error: {0}")]
Network(String),
#[error("Invalid configuration: {0}")]
Config(String),
#[error("Timeout: {0}")]
Timeout(String),
#[error("Unsupported operation: {0}")]
Unsupported(String),
#[error("Pool already exists: {0}")]
PoolAlreadyExists(String),
#[error("Not local machine: {0}")]
NotLocal(String),
#[error("Not remote machine: {0}")]
NotRemote(String),
}
impl From<io::Error> for TcpTargetError {
fn from(error: io::Error) -> Self {
TcpTargetError::Io(error.to_string())
}
}
impl From<serde_json::Error> for TcpTargetError {
fn from(error: serde_json::Error) -> Self {
TcpTargetError::Serialization(error.to_string())
}
}
impl From<&str> for TcpTargetError {
fn from(value: &str) -> Self {
TcpTargetError::Protocol(value.to_string())
}
}
impl From<String> for TcpTargetError {
fn from(value: String) -> Self {
TcpTargetError::Protocol(value)
}
}
impl From<rsa::errors::Error> for TcpTargetError {
fn from(error: rsa::errors::Error) -> Self {
TcpTargetError::Crypto(error.to_string())
}
}
impl From<ed25519_dalek::SignatureError> for TcpTargetError {
fn from(error: ed25519_dalek::SignatureError) -> Self {
TcpTargetError::Crypto(error.to_string())
}
}
impl From<ring::error::Unspecified> for TcpTargetError {
fn from(error: ring::error::Unspecified) -> Self {
TcpTargetError::Crypto(error.to_string())
}
}
impl From<base64::DecodeError> for TcpTargetError {
fn from(error: base64::DecodeError) -> Self {
TcpTargetError::Serialization(error.to_string())
}
}
impl From<pem::PemError> for TcpTargetError {
fn from(error: pem::PemError) -> Self {
TcpTargetError::Crypto(error.to_string())
}
}
impl From<rmp_serde::encode::Error> for TcpTargetError {
fn from(error: rmp_serde::encode::Error) -> Self {
TcpTargetError::Serialization(error.to_string())
}
}
impl From<rmp_serde::decode::Error> for TcpTargetError {
fn from(error: rmp_serde::decode::Error) -> Self {
TcpTargetError::Serialization(error.to_string())
}
}
|