Skip to content

Commit

Permalink
Rename ConnectionClosed to the more correct ConnectionAborted
Browse files Browse the repository at this point in the history
  • Loading branch information
rmja committed Oct 24, 2023
1 parent eaeae5f commit 3b0b27b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ pub enum Error {
AlreadySent,
/// An invalid number of bytes were written to request body
IncorrectBodyWritten,
/// The underlying connection was closed
ConnectionClosed,
/// The underlying connection was closed while being used
ConnectionAborted,
}

impl embedded_io::Error for Error {
fn kind(&self) -> embedded_io::ErrorKind {
match self {
Error::Network(kind) => *kind,
Error::ConnectionClosed => embedded_io::ErrorKind::NotConnected,
Error::ConnectionAborted => embedded_io::ErrorKind::ConnectionAborted,
_ => embedded_io::ErrorKind::Other,
}
}
Expand All @@ -60,7 +60,7 @@ impl From<embedded_io::ErrorKind> for Error {
impl<E: embedded_io::Error> From<ReadExactError<E>> for Error {
fn from(value: ReadExactError<E>) -> Self {
match value {
ReadExactError::UnexpectedEof => Error::ConnectionClosed,
ReadExactError::UnexpectedEof => Error::ConnectionAborted,
ReadExactError::Other(e) => Error::Network(e.kind()),
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ where
})?;

if n == 0 {
return Err(Error::ConnectionClosed);
return Err(Error::ConnectionAborted);
}

pos += n;
Expand Down Expand Up @@ -413,7 +413,7 @@ where
.map(|data| &data[..data.len().min(self.remaining)])?;

if loaded.is_empty() {
return Err(Error::ConnectionClosed);
return Err(Error::ConnectionAborted);
}

Ok(loaded)
Expand Down

0 comments on commit 3b0b27b

Please sign in to comment.