Skip to content

Commit

Permalink
Implement Default for ClosedStream
Browse files Browse the repository at this point in the history
This allows us to remove the `#[doc(hidden)] pub fn new() -> Self`.
  • Loading branch information
gretchenfrage authored and Ralith committed Dec 20, 2024
1 parent 43b74b6 commit 870375c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
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

0 comments on commit 870375c

Please sign in to comment.