diff --git a/quinn-proto/src/endpoint.rs b/quinn-proto/src/endpoint.rs index ae8b1f810..ff468005e 100644 --- a/quinn-proto/src/endpoint.rs +++ b/quinn-proto/src/endpoint.rs @@ -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 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