pub struct Frame<'a> { /* private fields */ }Expand description
An HTTP3 frame.
Implementations§
Source§impl<'a> Frame<'a>
impl<'a> Frame<'a>
Sourcepub fn new_headers(payload: Cow<'a, [u8]>) -> Self
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.
Sourcepub fn new_settings(payload: Cow<'a, [u8]>) -> Self
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.
Sourcepub fn new_webtransport(session_id: SessionId) -> Self
pub fn new_webtransport(session_id: SessionId) -> Self
Creates a new frame of type FrameKind::WebTransport.
Sourcepub fn new_data(payload: Cow<'a, [u8]>) -> Self
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.
Sourcepub fn new_exercise(id: VarInt, payload: Cow<'a, [u8]>) -> Self
pub fn new_exercise(id: VarInt, payload: Cow<'a, [u8]>) -> Self
Creates a new frame of type FrameKind::Exercise.
§Panics
- Panics if the
payloadsize if greater thanVarInt::MAX. - Panics if
idis not a valid exercise (seeFrameKind::is_id_exercise).
Sourcepub fn read<R>(bytes_reader: &mut R) -> Result<Option<Self>, ParseError>where
R: BytesReader<'a>,
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.
Sourcepub async fn read_async<R>(reader: &mut R) -> Result<Frame<'a>, IoReadError>
pub async fn read_async<R>(reader: &mut R) -> Result<Frame<'a>, IoReadError>
Reads a Frame from a reader.
Sourcepub fn read_from_buffer(
buffer_reader: &mut BufferReader<'a>,
) -> Result<Option<Self>, ParseError>
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.
Sourcepub fn write<W>(&self, bytes_writer: &mut W) -> Result<(), EndOfBuffer>where
W: BytesWriter,
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.
Sourcepub async fn write_async<W>(&self, writer: &mut W) -> Result<(), IoWriteError>
pub async fn write_async<W>(&self, writer: &mut W) -> Result<(), IoWriteError>
Sourcepub fn write_to_buffer(
&self,
buffer_writer: &mut BufferWriter<'_>,
) -> Result<(), EndOfBuffer>
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.
Sourcepub fn write_size(&self) -> usize
pub fn write_size(&self) -> usize
Returns the needed capacity to write this frame into a buffer.
Sourcepub fn session_id(&self) -> Option<SessionId>
pub fn session_id(&self) -> Option<SessionId>
Returns the SessionId if frame is FrameKind::WebTransport,
otherwise returns None.