Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trivial SendStream error cleanup #1872

Merged
merged 2 commits into from
May 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions quinn/src/send_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,17 @@ impl From<StoppedError> for WriteError {
}
}

impl From<WriteError> for io::Error {
fn from(x: WriteError) -> Self {
use self::WriteError::*;
let kind = match x {
Stopped(_) | ZeroRttRejected => io::ErrorKind::ConnectionReset,
ConnectionLost(_) | ClosedStream => io::ErrorKind::NotConnected,
};
Self::new(kind, x)
}
}

/// Errors that arise while monitoring for a send stream stop from the peer
#[derive(Debug, Error, Clone, PartialEq, Eq)]
pub enum StoppedError {
Expand All @@ -478,12 +489,12 @@ pub enum StoppedError {
ZeroRttRejected,
}

impl From<WriteError> for io::Error {
fn from(x: WriteError) -> Self {
use self::WriteError::*;
impl From<StoppedError> for io::Error {
Ralith marked this conversation as resolved.
Show resolved Hide resolved
fn from(x: StoppedError) -> Self {
use StoppedError::*;
let kind = match x {
Stopped(_) | ZeroRttRejected => io::ErrorKind::ConnectionReset,
ConnectionLost(_) | ClosedStream => io::ErrorKind::NotConnected,
ZeroRttRejected => io::ErrorKind::ConnectionReset,
ConnectionLost(_) => io::ErrorKind::NotConnected,
};
Self::new(kind, x)
}
Expand Down