Stream

Struct Stream 

Source
pub struct Stream<K, S> { /* private fields */ }
Expand description

A QUIC/HTTP3/WebTransport stream.

Implementations§

Source§

impl Stream<BiRemote, Quic>

Source

pub fn accept_bi() -> Self

Creates a new remote-initialized bidirectional stream.

Source

pub fn upgrade(self) -> StreamBiRemoteH3

Upgrades to an HTTP3 stream.

Source§

impl Stream<BiRemote, H3>

Source

pub fn read_frame<'a, R>( &mut self, bytes_reader: &mut R, ) -> Result<Option<Frame<'a>>, ErrorCode>
where R: BytesReader<'a>,

Source

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

Source

pub fn read_frame_from_buffer<'a>( &mut self, buffer_reader: &mut BufferReader<'a>, ) -> Result<Option<Frame<'a>>, ErrorCode>

Source

pub fn write_frame<W>( &self, frame: Frame<'_>, bytes_writer: &mut W, ) -> Result<(), EndOfBuffer>
where W: BytesWriter,

Source

pub async fn write_frame_async<W>( &self, frame: Frame<'_>, writer: &mut W, ) -> Result<(), IoWriteError>
where W: AsyncWrite + Unpin + ?Sized,

Source

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

Source

pub fn upgrade(self, session_id: SessionId) -> StreamBiRemoteWT

Upgrades to a WebTransport stream.

Note: upgrade should be performed only when FrameKind::WebTransport is received as first frame on this HTTP3 stream.

Source

pub fn into_session(self, session_request: SessionRequest) -> StreamSession

Converts the stream into a StreamSession.

Source§

impl Stream<BiRemote, WT>

Source

pub fn session_id(&self) -> SessionId

Returns the SessionId associated with this stream.

Source§

impl Stream<BiLocal, Quic>

Source

pub fn open_bi() -> Self

Creates a new locally-initialized bidirectional stream.

Source

pub fn upgrade(self) -> StreamBiLocalH3

Upgrades to an HTTP3 stream.

Source§

impl Stream<BiLocal, H3>

Source

pub fn read_frame<'a, R>( &self, bytes_reader: &mut R, ) -> Result<Option<Frame<'a>>, ErrorCode>
where R: BytesReader<'a>,

Source

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

Source

pub fn read_frame_from_buffer<'a>( &self, buffer_reader: &mut BufferReader<'a>, ) -> Result<Option<Frame<'a>>, ErrorCode>

Source

pub fn write_frame<W>( &mut self, frame: Frame<'_>, bytes_writer: &mut W, ) -> Result<(), EndOfBuffer>
where W: BytesWriter,

See Frame::write.

§Panics

Panics if FrameKind::WebTransport (use upgrade for that).

Source

pub async fn write_frame_async<W>( &mut self, frame: Frame<'_>, writer: &mut W, ) -> Result<(), IoWriteError>
where W: AsyncWrite + Unpin + ?Sized,

See Frame::write_async.

§Panics

Panics if FrameKind::WebTransport (use upgrade for that).

Source

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

See Frame::write_to_buffer.

§Panics

Panics if FrameKind::WebTransport (use upgrade for that).

Source

pub fn upgrade<W>( self, session_id: SessionId, bytes_writer: &mut W, ) -> StreamBiLocalWT
where W: BytesWriter,

Upgrades to a WebTransport stream.

§Panics
  • Panics if any other I/O operation has been performed on this stream before upgrade.
  • Panics if bytes_writer does not have enough capacity. See Self::upgrade_size.
Source

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

Upgrades to a WebTransport stream.

§Panics
  • Panics if any other I/O operation has been performed on this stream before upgrade.
Source

pub fn upgrade_size(&self, session_id: SessionId) -> usize

Returns the needed capacity for upgrade via Self::upgrade.

Source

pub fn into_session(self, session_request: SessionRequest) -> StreamSession

Converts the stream into a StreamSession.

Source§

impl Stream<BiLocal, WT>

Source

pub fn session_id(&self) -> SessionId

Returns the SessionId associated with this stream.

Source§

impl Stream<UniRemote, Quic>

Source

pub fn accept_uni() -> Self

Creates a new remote-initialized unidirectional stream.

Source

pub fn upgrade<'a, R>( self, bytes_reader: &mut R, ) -> Result<MaybeUpgradeH3, ErrorCode>
where R: BytesReader<'a>,

Upgrades to an HTTP3 stream.

Because bytes_reader could not contain all required data, this behaves more like an attempt of upgrading.

In case there are no enough information, MaybeUpgradeH3::Quic (i.e, self) will be returned.

If the stream type is unknown ErrorCode::StreamCreation is returned. In that case, MUST NOT consider unknown stream types to be a connection error of any kind.

Source

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

Upgrades to an HTTP3 stream.

Source§

impl Stream<UniRemote, H3>

Source

pub fn read_frame<'a, R>( &mut self, bytes_reader: &mut R, ) -> Result<Option<Frame<'a>>, ErrorCode>
where R: BytesReader<'a>,

See Frame::read.

§Panics

Panics if the stream kind is StreamKind::WebTransport. In that case, use upgrade method.

Source

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

See Frame::read_async.

§Panics

Panics if the stream kind is StreamKind::WebTransport. In that case, use upgrade method.

Source

pub fn read_frame_from_buffer<'a>( &mut self, buffer_reader: &mut BufferReader<'a>, ) -> Result<Option<Frame<'a>>, ErrorCode>

See Frame::read_from_buffer.

§Panics

Panics if the stream kind is StreamKind::WebTransport. In that case, use upgrade method.

Source

pub fn upgrade(self) -> StreamUniRemoteWT

Upgrades to a WebTransport stream.

§Panics

Panics if the stream kind is not StreamKind::WebTransport.

Source

pub fn kind(&self) -> StreamKind

Returns the StreamKind associated with the stream.

Source

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

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

Source§

impl Stream<UniRemote, WT>

Source

pub fn session_id(&self) -> SessionId

Returns the SessionId associated with this stream.

Source§

impl Stream<UniLocal, Quic>

Source

pub fn open_uni() -> Self

Creates a new locally-initialized unidirectional stream.

Source

pub fn upgrade<W>( self, stream_header: StreamHeader, bytes_writer: &mut W, ) -> StreamUniLocalH3
where W: BytesWriter,

Upgrades to an HTTP3 stream.

§Panics

Panics if bytes_writer does not have enough capacity to write the stream_header. Check it with Self::upgrade_size.

Source

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

Upgrades to an HTTP3 stream.

Source

pub fn upgrade_size(stream_header: StreamHeader) -> usize

Returns the buffer capacity needed for Self::upgrade.

Source§

impl Stream<UniLocal, H3>

Source

pub fn write_frame<W>( &mut self, frame: Frame<'_>, bytes_writer: &mut W, ) -> Result<(), EndOfBuffer>
where W: BytesWriter,

See Frame::write.

§Panics

Panics if the stream kind is StreamKind::WebTransport. In that case, use upgrade method.

Source

pub async fn write_frame_async<W>( &mut self, frame: Frame<'_>, writer: &mut W, ) -> Result<(), IoWriteError>
where W: AsyncWrite + Unpin + ?Sized,

See Frame::write_async.

§Panics

Panics if the stream kind is StreamKind::WebTransport. In that case, use upgrade method.

Source

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

See Frame::write_to_buffer.

§Panics

Panics if the stream kind is StreamKind::WebTransport. In that case, use upgrade method.

Source

pub fn upgrade(self) -> StreamUniLocalWT

Upgrades to a WebTransport stream.

§Panics

Panics if the stream kind is not StreamKind::WebTransport.

Source

pub fn kind(&self) -> StreamKind

Returns the StreamKind associated with the stream.

Source

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

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

Source§

impl Stream<UniLocal, WT>

Source

pub fn session_id(&self) -> SessionId

Returns the SessionId associated with this stream.

Source§

impl Stream<Bi, Session>

Source

pub fn read_frame<'a, R>( &self, bytes_reader: &mut R, ) -> Result<Option<Frame<'a>>, ErrorCode>
where R: BytesReader<'a>,

Source

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

Source

pub fn read_frame_from_buffer<'a>( &self, buffer_reader: &mut BufferReader<'a>, ) -> Result<Option<Frame<'a>>, ErrorCode>

Source

pub fn write_frame<W>( &self, frame: Frame<'_>, bytes_writer: &mut W, ) -> Result<(), EndOfBuffer>
where W: BytesWriter,

Source

pub async fn write_frame_async<W>( &self, frame: Frame<'_>, writer: &mut W, ) -> Result<(), IoWriteError>
where W: AsyncWrite + Unpin + ?Sized,

Source

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

Source

pub fn request(&self) -> &SessionRequest

Returns the SessionRequest associated.

Trait Implementations§

Source§

impl<K: Debug, S: Debug> Debug for Stream<K, S>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<K, S> Freeze for Stream<K, S>
where K: Freeze, S: Freeze,

§

impl<K, S> RefUnwindSafe for Stream<K, S>

§

impl<K, S> Send for Stream<K, S>
where K: Send, S: Send,

§

impl<K, S> Sync for Stream<K, S>
where K: Sync, S: Sync,

§

impl<K, S> Unpin for Stream<K, S>
where K: Unpin, S: Unpin,

§

impl<K, S> UnwindSafe for Stream<K, S>
where K: UnwindSafe, S: UnwindSafe,

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.