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

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]

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[..]);

Returns the total length of the RawFrame, including both headers, as well as the entire payload.

Returns a Vec of bytes representing the serialized (on-the-wire) representation of this raw frame.

Returns a FrameHeader instance corresponding to the headers of the RawFrame.

Returns a slice representing the payload of the RawFrame.

Trait Implementations

impl PartialEq for RawFrame
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Debug for RawFrame
[src]

Formats the value using the given formatter. Read more

impl Clone for RawFrame
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl AsRef<[u8]> for RawFrame
[src]

Important traits for &'a [u8]

Performs the conversion.

impl From<Vec<u8>> for RawFrame
[src]

Provide a conversion from a Vec.

This conversion is unchecked and could cause the resulting RawFrame to be an invalid HTTP/2 frame.

Performs the conversion.

impl<'a> From<&'a [u8]> for RawFrame
[src]

Performs the conversion.

impl FrameIR for RawFrame
[src]

RawFrames can be serialized to an on-the-wire format.

Write out the on-the-wire representation of the frame into the given FrameBuilder.

Important traits for Vec<u8>

Auto Trait Implementations

impl Send for RawFrame

impl Sync for RawFrame