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

Implement Default for ClosedStream #2103

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
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
9 changes: 1 addition & 8 deletions quinn-proto/src/connection/streams/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,19 +508,12 @@ impl ShouldTransmit {
}

/// Error indicating that a stream has not been opened or has already been finished or reset
#[derive(Debug, Error, Clone, PartialEq, Eq)]
#[derive(Debug, Default, Error, Clone, PartialEq, Eq)]
#[error("closed stream")]
pub struct ClosedStream {
_private: (),
}

impl ClosedStream {
#[doc(hidden)] // For use in quinn only
pub fn new() -> Self {
Self { _private: () }
}
}

impl From<ClosedStream> for io::Error {
fn from(x: ClosedStream) -> Self {
Self::new(io::ErrorKind::NotConnected, x)
Expand Down
2 changes: 1 addition & 1 deletion quinn/src/send_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl SendStream {
conn.wake();
Ok(())
}
Err(FinishError::ClosedStream) => Err(ClosedStream::new()),
Err(FinishError::ClosedStream) => Err(ClosedStream::default()),
// Harmless. If the application needs to know about stopped streams at this point, it
// should call `stopped`.
Err(FinishError::Stopped(_)) => Ok(()),
Expand Down
Loading