Frame

Struct Frame 

Source
pub struct Frame<'a> { /* private fields */ }
Expand description

An HTTP3 frame.

Implementations§

Source§

impl<'a> Frame<'a>

Source

pub fn new_headers(payload: Cow<'a, [u8]>) -> Self

Creates a new frame of type FrameKind::Headers.

§Panics

Panics if the payload size if greater than VarInt::MAX.

Source

pub fn new_settings(payload: Cow<'a, [u8]>) -> Self

Creates a new frame of type FrameKind::Settings.

§Panics

Panics if the payload size if greater than VarInt::MAX.

Source

pub fn new_webtransport(session_id: SessionId) -> Self

Creates a new frame of type FrameKind::WebTransport.

Source

pub fn new_data(payload: Cow<'a, [u8]>) -> Self

Creates a new frame of type FrameKind::Data.

§Panics

Panics if the payload size if greater than VarInt::MAX.

Source

pub fn new_exercise(id: VarInt, payload: Cow<'a, [u8]>) -> Self

Creates a new frame of type FrameKind::Exercise.

§Panics
Source

pub fn read<R>(bytes_reader: &mut R) -> Result<Option<Self>, ParseError>
where R: BytesReader<'a>,

Reads a Frame from a BytesReader.

It returns None if the bytes_reader does not contain enough bytes to parse an entire frame.

In case None or Err, bytes_reader might be partially read.

Source

pub async fn read_async<R>(reader: &mut R) -> Result<Frame<'a>, IoReadError>
where R: AsyncRead + Unpin + ?Sized,

Reads a Frame from a reader.

Source

pub fn read_from_buffer( buffer_reader: &mut BufferReader<'a>, ) -> Result<Option<Self>, ParseError>

Reads a Frame from a BufferReader.

It returns None if the buffer_reader does not contain enough bytes to parse an entire frame.

In case None or Err, buffer_reader offset if not advanced.

Source

pub fn write<W>(&self, bytes_writer: &mut W) -> Result<(), EndOfBuffer>
where W: BytesWriter,

Writes a Frame into a BytesWriter.

It returns Err if the bytes_writer does not have enough capacity to write the entire frame. See Self::write_size to retrieve the exact amount of required capacity.

In case Err, bytes_writer might be partially written.

§Panics

Panics if the payload size if greater than VarInt::MAX.

Source

pub async fn write_async<W>(&self, writer: &mut W) -> Result<(), IoWriteError>
where W: AsyncWrite + Unpin + ?Sized,

Writes a Frame into a writer.

§Panics

Panics if the payload size if greater than VarInt::MAX.

Source

pub fn write_to_buffer( &self, buffer_writer: &mut BufferWriter<'_>, ) -> Result<(), EndOfBuffer>

Writes this Frame into a buffer via BufferWriter.

In case Err, buffer_writer is not advanced.

§Panics

Panics if the payload size if greater than VarInt::MAX.

Source

pub fn write_size(&self) -> usize

Returns the needed capacity to write this frame into a buffer.

Source

pub const fn kind(&self) -> FrameKind

Returns the FrameKind of this Frame.

Source

pub fn payload(&self) -> &[u8]

Returns the payload of this Frame.

Source

pub fn session_id(&self) -> Option<SessionId>

Returns the SessionId if frame is FrameKind::WebTransport, otherwise returns None.

Trait Implementations§

Source§

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

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze 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> 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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.