Struct httpbis::solicit::frame::RawFrame [−][src]
pub struct RawFrame { pub raw_content: Bytes, }
A struct that defines the format of the raw HTTP/2 frame, i.e. the frame as it is read from the wire.
This format is defined in section 4.1. of the HTTP/2 spec.
The RawFrame
struct simply stores the raw components of an HTTP/2 frame:
its header and the payload as a sequence of bytes.
It does not try to interpret the payload bytes, nor do any validation in terms of its validity based on the frame type given in the header. It is simply a wrapper around the two parts of an HTTP/2 frame.
Fields
raw_content: Bytes
The raw frame representation, including both the raw header representation (in the first 9 bytes), followed by the raw payload representation.
Methods
impl RawFrame
[src]
impl RawFrame
pub fn parse<B: Into<Bytes>>(into_buf: B) -> ParseFrameResult<RawFrame>
[src]
pub fn parse<B: Into<Bytes>>(into_buf: B) -> ParseFrameResult<RawFrame>
Parses a RawFrame
from the bytes starting at the beginning of the given buffer.
Returns the None
variant when it is not possible to parse a raw frame from the buffer
(due to there not being enough bytes in the buffer). If the RawFrame
is successfully
parsed it returns the frame, borrowing a part of the original buffer. Therefore, this
method makes no copies, nor does it perform any extra allocations.
Examples
use httpbis::solicit::frame::RawFrame; let buf = b"123"; // Not enough bytes for even the header of the frame assert!(RawFrame::parse(&buf[..]).is_none());
use httpbis::solicit::frame::RawFrame; let buf = vec![0, 0, 1, 0, 0, 0, 0, 0, 0]; // Full header, but not enough bytes for the payload assert!(RawFrame::parse(&buf[..]).is_none());
use httpbis::solicit::frame::RawFrame; let buf = vec![0, 0, 1, 0, 0, 0, 0, 0, 0, 1]; // A full frame is extracted, even if in this case the frame itself is not valid (a DATA // frame associated to stream 0 is not valid in HTTP/2!). This, however, is not the // responsibility of the RawFrame. let frame = RawFrame::parse(&buf[..]).unwrap(); assert_eq!(frame.as_ref(), &buf[..]);
pub fn as_frame_ref(&self) -> RawFrameRef
[src]
pub fn as_frame_ref(&self) -> RawFrameRef
pub fn frame_type(&self) -> u8
[src]
pub fn frame_type(&self) -> u8
pub fn len(&self) -> usize
[src]
pub fn len(&self) -> usize
Returns the total length of the RawFrame
, including both headers, as well as the entire
payload.
pub fn serialize(&self) -> &Bytes
[src]
pub fn serialize(&self) -> &Bytes
Returns a Vec
of bytes representing the serialized (on-the-wire)
representation of this raw frame.
pub fn header(&self) -> FrameHeader
[src]
pub fn header(&self) -> FrameHeader
Returns a FrameHeader
instance corresponding to the headers of the
RawFrame
.
pub fn get_stream_id(&self) -> StreamId
[src]
pub fn get_stream_id(&self) -> StreamId
pub fn payload(&self) -> Bytes
[src]
pub fn payload(&self) -> Bytes
Returns a slice representing the payload of the RawFrame
.
Trait Implementations
impl PartialEq for RawFrame
[src]
impl PartialEq for RawFrame
fn eq(&self, other: &RawFrame) -> bool
[src]
fn eq(&self, other: &RawFrame) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &RawFrame) -> bool
[src]
fn ne(&self, other: &RawFrame) -> bool
This method tests for !=
.
impl Debug for RawFrame
[src]
impl Debug for RawFrame
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Clone for RawFrame
[src]
impl Clone for RawFrame
fn clone(&self) -> RawFrame
[src]
fn clone(&self) -> RawFrame
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl AsRef<[u8]> for RawFrame
[src]
impl AsRef<[u8]> for RawFrame
impl From<Vec<u8>> for RawFrame
[src]
impl From<Vec<u8>> for RawFrame
Provide a conversion from a Vec
.
This conversion is unchecked and could cause the resulting RawFrame
to be an
invalid HTTP/2 frame.
impl<'a> From<&'a [u8]> for RawFrame
[src]
impl<'a> From<&'a [u8]> for RawFrame
impl FrameIR for RawFrame
[src]
impl FrameIR for RawFrame
RawFrame
s can be serialized to an on-the-wire format.
fn serialize_into(self, b: &mut FrameBuilder)
[src]
fn serialize_into(self, b: &mut FrameBuilder)
Write out the on-the-wire representation of the frame into the given FrameBuilder
.
fn serialize_into_vec(self) -> Vec<u8> where
Self: Sized,
[src]
fn serialize_into_vec(self) -> Vec<u8> where
Self: Sized,