Skip to content

Commit

Permalink
Add Error::is_go_away() and Error::is_remote()
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmonstar committed Jan 6, 2022
1 parent c876dda commit 6336cc3
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl Error {
}
}

/// Returns the true if the error is an io::Error
/// Returns true if the error is an io::Error
pub fn is_io(&self) -> bool {
match self.kind {
Kind::Io(_) => true,
Expand Down Expand Up @@ -86,6 +86,21 @@ impl Error {
kind: Kind::Io(err),
}
}

/// Returns true if the error is from a `GOAWAY`.
pub fn is_go_away(&self) -> bool {
matches!(self.kind, Kind::GoAway(..))
}

/// Returns true if the error was received in a frame from the remote.
///
/// Such as from a received `RST_STREAM` or `GOAWAY` frame.
pub fn is_remote(&self) -> bool {
matches!(
self.kind,
Kind::GoAway(_, _, Initiator::Remote) | Kind::Reset(_, _, Initiator::Remote)
)
}
}

impl From<proto::Error> for Error {
Expand Down

0 comments on commit 6336cc3

Please sign in to comment.