Skip to main content

SendStream

Enum SendStream 

Source
pub enum SendStream {
    Quic(SendStream),
}
Expand description

A transport-agnostic send stream.

Variants§

§

Quic(SendStream)

Raw QUIC send stream.

Implementations§

Source§

impl SendStream

Source

pub fn stream_id(&self) -> u64

Get the QUIC stream ID (transport-level identifier).

Source

pub async fn write_all(&mut self, buf: &[u8]) -> Result<(), TransportError>

Write all bytes to the stream.

Fails with TransportError::Stopped carrying the peer’s application error code if the peer sent STOP_SENDING.

Source

pub fn finish(&mut self) -> Result<(), TransportError>

Finish the stream (send FIN).

Source

pub fn reset(&mut self, code: u64) -> Result<(), TransportError>

Reset the stream, telling the peer transmission was abandoned and handing it code as the RESET_STREAM application error code.

This is the only way to abandon a send stream truthfully: simply dropping a SendStream sends a FIN instead, which tells the peer the stream ended cleanly. A forwarder that saw the far side reset must call this with the code it received, so a truncated stream is never laundered into a complete one.

§Errors
Source

pub fn set_priority(&self, priority: i32) -> Result<(), TransportError>

Set the stream’s send priority.

Streams with a higher priority have their locally buffered data transmitted first. Every stream starts at priority 0.

§Errors

TransportError::StreamClosed once the stream’s send state has been discarded — but only on the QUIC arm, and quinn keeps that state around for a while after a finish or reset, so this is not a reliable is the stream still live? probe. The WebTransport arm never reports it at all: wtransport discards the underlying error and always succeeds. Do not treat Ok(()) as proof the priority took effect.

Source

pub fn stopped( &self, ) -> impl Future<Output = Result<(), TransportError>> + Send + 'static

Resolve when this send half stops being useful.

write_all only reports STOP_SENDING when there is something to write, so a forwarder that has gone idle — the normal state of a stream waiting on its source — never learns that the peer walked away. This is the watcher for that case: it borrows nothing, so it can sit in a select! beside the read branch for the stream’s whole life. The four outcomes, all measured against quinn 0.11.9:

  • The peer sent STOP_SENDINGTransportError::Stopped carrying the peer’s application error code, the same typed value a failed write_all produces, so a forwarder can mirror it verbatim with no new match arm.
  • The stream was finished and the peer acked every byte → Ok(()). quinn cannot tell that apart from the send state was discarded, so Ok(()) means this stream is over, never the peer is happy. It cannot fire on a live stream.
  • The connection was lost → TransportError::Connection.
  • The local side reset the stream → this future never resolves. quinn keeps no stopped-notification for a stream it has locally reset, so a watcher held across a reset stays pending until the connection ends and holds a tokio::sync::Notify alive for that long. Retire the future before resetting.

The returned future is 'static: it holds a handle on the connection, not on self, so it may outlive this SendStream and be spawned or stored on its own.

§WebTransport arm

Reaches the same quinn future through webtransport::WtSendStream::quic_stream — spelled as code and not as an intra-doc link because the webtransport module is behind its own feature, so a link to it is broken in the default build and just doc-check runs cargo doc --workspace --no-deps without it. This bypasses wtransport’s own stopped, which collapses stopped / closed / disconnected into one error. One asymmetry the QUIC arm does not have: finish moves the inner wtransport stream out, so calling this afterwards yields a future that resolves immediately to TransportError::StreamClosed — the “finished and acked” case is unobservable there. Not yet exercised against a live WebTransport session.

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more