From 32b556555dd332c89f49a6345831ff3f7ddd8465 Mon Sep 17 00:00:00 2001 From: Benjamin Saunders Date: Sun, 19 May 2024 10:45:03 -0700 Subject: [PATCH] impl From for io::Error --- quinn/src/send_stream.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/quinn/src/send_stream.rs b/quinn/src/send_stream.rs index 049344797..0fd98e734 100644 --- a/quinn/src/send_stream.rs +++ b/quinn/src/send_stream.rs @@ -488,3 +488,14 @@ pub enum StoppedError { #[error("0-RTT rejected")] ZeroRttRejected, } + +impl From for io::Error { + fn from(x: StoppedError) -> Self { + use StoppedError::*; + let kind = match x { + ZeroRttRejected => io::ErrorKind::ConnectionReset, + ConnectionLost(_) => io::ErrorKind::NotConnected, + }; + Self::new(kind, x) + } +}