StreamHeader

Struct StreamHeader 

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

HTTP3 stream type.

Unidirectional HTTP3 streams have an header encoding the type.

Implementations§

Source§

impl StreamHeader

Source

pub const MAX_SIZE: usize = 16usize

Maximum number of bytes a StreamHeader can take over network.

Source

pub fn new_control() -> Self

Creates a new stream header of type StreamKind::Control.

Source

pub fn new_webtransport(session_id: SessionId) -> Self

Creates a new stream header of type StreamKind::WebTransport.

Source

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

Reads a StreamHeader from a BytesReader.

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

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

Source

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

Reads a StreamHeader from a reader.

Source

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

Reads a StreamHeader from a BufferReader.

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

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 StreamHeader into a BytesWriter.

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

In case Err, bytes_writer might be partially written.

Source

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

Writes a StreamHeader into a writer.

Source

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

Writes this StreamHeader into a buffer via BufferWriter.

In case Err, buffer_writer is not advanced.

Source

pub fn write_size(&self) -> usize

Returns the needed capacity to write this stream header into a buffer.

Source

pub const fn kind(&self) -> StreamKind

Returns the StreamKind.

Source

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

Returns the SessionId if stream is StreamKind::WebTransport, otherwise returns None.

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