pub enum Frame<'a> {
Data {
stream: u32,
end_stream: bool,
data: &'a [u8],
},
Headers {
stream: u32,
end_stream: bool,
end_headers: bool,
block: &'a [u8],
},
Priority {
stream: u32,
},
RstStream {
stream: u32,
code: u32,
},
Settings {
ack: bool,
params: Vec<(u16, u32)>,
},
PushPromise {
stream: u32,
promised: u32,
end_headers: bool,
block: &'a [u8],
},
Ping {
ack: bool,
data: [u8; 8],
},
GoAway {
last_stream: u32,
code: u32,
debug: &'a [u8],
},
WindowUpdate {
stream: u32,
increment: u32,
},
Continuation {
stream: u32,
end_headers: bool,
block: &'a [u8],
},
Unknown {
kind: u8,
stream: u32,
},
}Expand description
One HTTP/2 frame, borrowing its payload from the input.
Variants§
Data
DATA (§6.1); padding removed.
Headers
HEADERS (§6.2); padding removed, priority fields read and dropped.
Fields
Priority
PRIORITY (§6.3), deprecated; read and ignored by the connection.
RstStream
RST_STREAM (§6.4).
Settings
SETTINGS (§6.5), on stream 0.
Fields
PushPromise
PUSH_PROMISE (§6.6); padding removed.
Fields
Ping
PING (§6.7), on stream 0.
GoAway
GOAWAY (§6.8), on stream 0.
Fields
WindowUpdate
WINDOW_UPDATE (§6.9); a zero increment is returned, not refused.
Continuation
CONTINUATION (§6.10).
Fields
Unknown
A frame of a type this crate does not know, which a recipient ignores (§4.1, §5.5).
Implementations§
Source§impl<'a> Frame<'a>
impl<'a> Frame<'a>
Sourcepub fn decode(
input: &'a [u8],
max_frame_size: u32,
) -> Result<(Frame<'a>, usize), DecodeError>
pub fn decode( input: &'a [u8], max_frame_size: u32, ) -> Result<(Frame<'a>, usize), DecodeError>
Decodes one frame from the front of input. Returns it and the octets
it used.
§Errors
Incomplete with the exact number of missing octets; TooLarge
"frame" for a payload length above max_frame_size, decided from
the header alone; Malformed "frame length", "padding",
"stream identifier", "SETTINGS_ENABLE_PUSH",
"SETTINGS_INITIAL_WINDOW_SIZE", "SETTINGS_MAX_FRAME_SIZE".
Sourcepub fn encode(&self, out: &mut Vec<u8>)
pub fn encode(&self, out: &mut Vec<u8>)
Appends the frame. No padding and no priority fields are written.
Frame::Unknown writes nothing: it carries no payload to send.
The caller keeps every payload within the peer’s
SETTINGS_MAX_FRAME_SIZE.