Add Error::is_go_away() and Error::is_remote()
This commit is contained in:
17
src/error.rs
17
src/error.rs
@@ -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 {
|
pub fn is_io(&self) -> bool {
|
||||||
match self.kind {
|
match self.kind {
|
||||||
Kind::Io(_) => true,
|
Kind::Io(_) => true,
|
||||||
@@ -86,6 +86,21 @@ impl Error {
|
|||||||
kind: Kind::Io(err),
|
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 {
|
impl From<proto::Error> for Error {
|
||||||
|
|||||||
Reference in New Issue
Block a user