Skip to content

Commit

Permalink
feat: add Error::is_library method
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmonstar committed Apr 13, 2023
1 parent 481c31d commit 8088ca6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@ impl Error {
Kind::GoAway(_, _, Initiator::Remote) | Kind::Reset(_, _, Initiator::Remote)
)
}

/// Returns true if the error was created by `h2.
///
/// Such as noticing some protocol error and sending a GOAWAY or RST_STREAM.
pub fn is_library(&self) -> bool {
matches!(
self.kind,
Kind::GoAway(_, _, Initiator::Library) | Kind::Reset(_, _, Initiator::Library)
)
}
}

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

0 comments on commit 8088ca6

Please sign in to comment.