Skip to main content

LengthPrefixedFrame

Struct LengthPrefixedFrame 

Source
pub struct LengthPrefixedFrame { /* private fields */ }
Expand description

Decodes arbitrary fragmented or coalesced HTTP/2 DATA payloads.

Length limits are checked before allocating a message body. A failed decoder rejects further input until reset. An error from push discards any messages completed in that call; callers must terminate the affected RPC stream.

Implementations§

Source§

impl LengthPrefixedFrame

Source

pub fn new(max_message_size: usize) -> Self

Creates a decoder with a maximum encoded payload length in bytes.

Source

pub fn push(&mut self, chunk: &[u8]) -> Result<Vec<AlignedMessageBuf>, Status>

Consumes one DATA chunk and returns every complete message in wire order.

Empty chunks are valid. Partial headers and bodies remain buffered until the next call. Compression negotiation and decompression belong to the caller.

§Errors

Returns internal for an invalid compressed flag, resource exhausted for oversized messages or allocation failure, or the previous decoder failure.

Source

pub fn finish(&mut self) -> Result<(), Status>

Validates the end of a DATA stream, including an empty stream.

§Errors

Returns internal for a truncated header or body, or the previous failure.

Source

pub fn reset(&mut self)

Discards buffered input and failure state before decoding a different stream.

Trait Implementations§

Source§

impl Debug for LengthPrefixedFrame

Source§

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

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

impl Default for LengthPrefixedFrame

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> 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> Same for T

Source§

type Output = T

Should always be Self
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.