mirror of
https://github.com/n0-computer/noq.git
synced 2026-10-03 21:03:15 +00:00
impl From<ConnectError> for io::Error
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use std::{
|
||||
collections::{HashMap, VecDeque},
|
||||
convert::TryFrom,
|
||||
fmt, iter,
|
||||
fmt, io, iter,
|
||||
net::{IpAddr, SocketAddr},
|
||||
ops::{Index, IndexMut},
|
||||
sync::Arc,
|
||||
@@ -844,6 +844,19 @@ pub enum ConnectError {
|
||||
UnsupportedVersion,
|
||||
}
|
||||
|
||||
// For compatibility with API consumers
|
||||
impl From<ConnectError> for io::Error {
|
||||
fn from(x: ConnectError) -> io::Error {
|
||||
use ConnectError::*;
|
||||
let kind = match x {
|
||||
InvalidDnsName(_) | InvalidRemoteAddress(_) => io::ErrorKind::InvalidData,
|
||||
EndpointStopping | TooManyConnections | NoDefaultClientConfig => io::ErrorKind::Other,
|
||||
UnsupportedVersion => io::ErrorKind::InvalidInput,
|
||||
};
|
||||
io::Error::new(kind, x)
|
||||
}
|
||||
}
|
||||
|
||||
/// Reset Tokens which are associated with peer socket addresses
|
||||
///
|
||||
/// The standard `HashMap` is used since both `SocketAddr` and `ResetToken` are
|
||||
|
||||
Reference in New Issue
Block a user