pub enum SendStream {
Quic(SendStream),
}Expand description
A transport-agnostic send stream.
Variants§
Quic(SendStream)
Raw QUIC send stream.
Implementations§
Source§impl SendStream
impl SendStream
Sourcepub async fn write_all(&mut self, buf: &[u8]) -> Result<(), TransportError>
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.
Sourcepub fn finish(&mut self) -> Result<(), TransportError>
pub fn finish(&mut self) -> Result<(), TransportError>
Finish the stream (send FIN).
Sourcepub fn reset(&mut self, code: u64) -> Result<(), TransportError>
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
TransportError::StreamClosedif the stream was already finished or reset.TransportError::Writeifcodeis outside the QUIC varint range (0..2^62). Nothing is sent in that case and the stream stays usable.
Sourcepub fn set_priority(&self, priority: i32) -> Result<(), TransportError>
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.
Sourcepub fn stopped(
&self,
) -> impl Future<Output = Result<(), TransportError>> + Send + 'static
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_SENDING→TransportError::Stoppedcarrying the peer’s application error code, the same typed value a failedwrite_allproduces, 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, soOk(())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
resetstays pending until the connection ends and holds atokio::sync::Notifyalive 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.