Skip to content

Commit

Permalink
stream: reset method on SendStream
Browse files Browse the repository at this point in the history
  • Loading branch information
BiagioFesta committed Jun 27, 2023
1 parent 54bc81a commit ffce537
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions wtransport/src/driver/streams/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ impl QuicSendStream {
}
}

#[inline(always)]
pub fn reset(mut self, error_code: VarInt) {
self.0
.reset(varint_w2q(error_code))
.expect("Stream has been already reset")
}

#[inline(always)]
pub fn id(&self) -> StreamId {
streamid_q2w(self.0.id())
Expand Down
11 changes: 11 additions & 0 deletions wtransport/src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use tokio::io::ReadBuf;
use wtransport_proto::ids::SessionId;
use wtransport_proto::ids::StreamId;
use wtransport_proto::stream_header::StreamHeader;
use wtransport_proto::varint::VarInt;

/// A stream that can only be used to send data.
pub struct SendStream(QuicSendStream);
Expand Down Expand Up @@ -72,6 +73,16 @@ impl SendStream {
pub fn priority(&self) -> i32 {
self.0.priority()
}

/// Closes the send stream immediately.
///
/// No new data can be written after calling this method. Locally buffered data is dropped, and
/// previously transmitted data will no longer be retransmitted if lost. If an attempt has
/// already been made to finish the stream, the peer may still receive all written data.
#[inline(always)]
pub fn reset(self, error_code: VarInt) {
self.0.reset(error_code)
}
}

/// A stream that can only be used to receive data.
Expand Down

0 comments on commit ffce537

Please sign in to comment.