#[non_exhaustive]pub enum FrameError {
HeaderTooLarge {
limit: usize,
},
TooManyHeaders {
limit: usize,
},
InvalidHeader,
MissingContentLength,
DuplicateContentLength,
InvalidContentLength,
TooLarge {
length: Option<u64>,
limit: usize,
},
Truncated,
}Expand description
Why a byte stream could not be cut into messages.
Only TooLarge is recoverable: the decoder has
skipped (or is skipping) the oversized message without buffering it, and
the next message can be read. Every other error leaves the stream with no
reliable message boundary, so the decoder stops and returns the same error
from then on.
§Examples
use rpc_io::{FrameError, Framing, Limits};
let mut decoder = Framing::ContentLength.decoder(&Limits::new());
decoder.feed(b"Content-Length: 1x\r\n\r\n");
assert_eq!(decoder.next_frame(), Err(FrameError::InvalidContentLength));
assert!(!FrameError::InvalidContentLength.is_recoverable());Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
HeaderTooLarge
A header section exceeded Limits::max_header_bytes.
TooManyHeaders
A header section had more than Limits::max_headers lines.
InvalidHeader
A header line has no :, or its name is not an RFC 9110 token
(empty, or holding a space, a brace, or another separator).
MissingContentLength
A header section ended without a Content-Length header.
DuplicateContentLength
A header section has more than one Content-Length header.
InvalidContentLength
A Content-Length value is not a decimal integer that fits in 64 bits.
TooLarge
A message exceeded Limits::max_message_bytes. Recoverable: the
message is skipped without being buffered.
Fields
Truncated
The stream ended inside a message.
Implementations§
Source§impl FrameError
impl FrameError
Sourcepub const fn is_recoverable(&self) -> bool
pub const fn is_recoverable(&self) -> bool
Whether the decoder can go on to the next message.
§Examples
use rpc_io::FrameError;
assert!(FrameError::TooLarge { length: Some(9), limit: 8 }.is_recoverable());
assert!(!FrameError::Truncated.is_recoverable());Trait Implementations§
Source§impl Clone for FrameError
impl Clone for FrameError
impl Copy for FrameError
Source§impl Debug for FrameError
impl Debug for FrameError
Source§impl Display for FrameError
impl Display for FrameError
impl Eq for FrameError
Source§impl Error for FrameError
impl Error for FrameError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<FrameError> for Error
Available on crate feature std only.
impl From<FrameError> for Error
std only.