#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
#[non_exhaustive]
pub enum Http2Error {
BadPreface,
FrameTooLarge,
MalformedFrame,
InterleavedContinuation,
UnexpectedContinuation,
HeaderListTooLong,
TooManyStreams,
BufferOverflow,
HpackInvalidIndex,
HpackTruncated,
HpackIntegerOverflow,
HpackTableSizeExceeded,
HuffmanInvalid,
InvalidHeaderField,
InvalidStreamId,
}
impl Http2Error {
pub const fn as_str(self) -> &'static str {
match self {
Self::BadPreface => "bad-preface",
Self::FrameTooLarge => "frame-too-large",
Self::MalformedFrame => "malformed-frame",
Self::InterleavedContinuation => "interleaved-continuation",
Self::UnexpectedContinuation => "unexpected-continuation",
Self::HeaderListTooLong => "header-list-too-long",
Self::TooManyStreams => "too-many-streams",
Self::BufferOverflow => "buffer-overflow",
Self::HpackInvalidIndex => "hpack-invalid-index",
Self::HpackTruncated => "hpack-truncated",
Self::HpackIntegerOverflow => "hpack-integer-overflow",
Self::HpackTableSizeExceeded => "hpack-table-size-exceeded",
Self::HuffmanInvalid => "huffman-invalid",
Self::InvalidHeaderField => "invalid-header-field",
Self::InvalidStreamId => "invalid-stream-id",
}
}
}
impl std::fmt::Display for Http2Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
impl std::error::Error for Http2Error {}