Skip to main content

Frame

Enum Frame 

Source
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.

Fields

§stream: u32

The stream, never 0.

§end_stream: bool

END_STREAM.

§data: &'a [u8]

The data.

§

Headers

HEADERS (§6.2); padding removed, priority fields read and dropped.

Fields

§stream: u32

The stream, never 0.

§end_stream: bool

END_STREAM.

§end_headers: bool

END_HEADERS.

§block: &'a [u8]

The field block fragment.

§

Priority

PRIORITY (§6.3), deprecated; read and ignored by the connection.

Fields

§stream: u32

The stream, never 0.

§

RstStream

RST_STREAM (§6.4).

Fields

§stream: u32

The stream, never 0.

§code: u32

The error code.

§

Settings

SETTINGS (§6.5), on stream 0.

Fields

§ack: bool

ACK; an acknowledgement carries no parameters.

§params: Vec<(u16, u32)>

The parameters in order.

§

PushPromise

PUSH_PROMISE (§6.6); padding removed.

Fields

§stream: u32

The stream, never 0.

§promised: u32

The promised stream.

§end_headers: bool

END_HEADERS.

§block: &'a [u8]

The field block fragment.

§

Ping

PING (§6.7), on stream 0.

Fields

§ack: bool

ACK.

§data: [u8; 8]

The opaque data.

§

GoAway

GOAWAY (§6.8), on stream 0.

Fields

§last_stream: u32

The last stream the sender processed or might process.

§code: u32

The error code.

§debug: &'a [u8]

Additional debug data.

§

WindowUpdate

WINDOW_UPDATE (§6.9); a zero increment is returned, not refused.

Fields

§stream: u32

The stream, or 0 for the connection.

§increment: u32

The increment, 31 bits.

§

Continuation

CONTINUATION (§6.10).

Fields

§stream: u32

The stream, never 0.

§end_headers: bool

END_HEADERS.

§block: &'a [u8]

The field block fragment.

§

Unknown

A frame of a type this crate does not know, which a recipient ignores (§4.1, §5.5).

Fields

§kind: u8

The frame type.

§stream: u32

The stream.

Implementations§

Source§

impl<'a> Frame<'a>

Source

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".

Source

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.

Trait Implementations§

Source§

impl<'a> Clone for Frame<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Frame<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Eq for Frame<'a>

Source§

impl<'a> PartialEq for Frame<'a>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> StructuralPartialEq for Frame<'a>

Auto Trait Implementations§

§

impl<'a> Forget for Frame<'a>

§

impl<'a> Freeze for Frame<'a>

§

impl<'a> Move for Frame<'a>

§

impl<'a> RefUnwindSafe for Frame<'a>

§

impl<'a> Send for Frame<'a>

§

impl<'a> Sync for Frame<'a>

§

impl<'a> Unpin for Frame<'a>

§

impl<'a> UnsafeUnpin for Frame<'a>

§

impl<'a> UnwindSafe for Frame<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.