pub struct StreamHeader { /* private fields */ }Expand description
HTTP3 stream type.
Unidirectional HTTP3 streams have an header encoding the type.
Implementations§
Source§impl StreamHeader
impl StreamHeader
Sourcepub const MAX_SIZE: usize = 16usize
pub const MAX_SIZE: usize = 16usize
Maximum number of bytes a StreamHeader can take over network.
Sourcepub fn new_control() -> Self
pub fn new_control() -> Self
Creates a new stream header of type StreamKind::Control.
Sourcepub fn new_webtransport(session_id: SessionId) -> Self
pub fn new_webtransport(session_id: SessionId) -> Self
Creates a new stream header of type StreamKind::WebTransport.
Sourcepub fn read<'a, R>(bytes_reader: &mut R) -> Result<Option<Self>, ParseError>where
R: BytesReader<'a>,
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.
Sourcepub async fn read_async<R>(reader: &mut R) -> Result<Self, IoReadError>
pub async fn read_async<R>(reader: &mut R) -> Result<Self, IoReadError>
Reads a StreamHeader from a reader.
Sourcepub fn read_from_buffer(
buffer_reader: &mut BufferReader<'_>,
) -> Result<Option<Self>, ParseError>
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.
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 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.
Sourcepub async fn write_async<W>(&self, writer: &mut W) -> Result<(), IoWriteError>
pub async fn write_async<W>(&self, writer: &mut W) -> Result<(), IoWriteError>
Writes a StreamHeader into a writer.
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 StreamHeader into a buffer via BufferWriter.
In case Err, buffer_writer is not advanced.
Sourcepub fn write_size(&self) -> usize
pub fn write_size(&self) -> usize
Returns the needed capacity to write this stream header into a buffer.
Sourcepub const fn kind(&self) -> StreamKind
pub const fn kind(&self) -> StreamKind
Returns the StreamKind.
Sourcepub fn session_id(&self) -> Option<SessionId>
pub fn session_id(&self) -> Option<SessionId>
Returns the SessionId if stream is StreamKind::WebTransport,
otherwise returns None.