Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions bun.lock
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"rimraf": "^6.0.1",
"tsx": "^4.20.5",
"typescript": "^5.9.2",
"ws": "^8.16.0",
},
},
},
Expand Down Expand Up @@ -515,8 +514,6 @@

"wrap-ansi-cjs": ["wrap-ansi@7.0.0", "", { "dependencies": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", "strip-ansi": "^6.0.0" } }, "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q=="],

"ws": ["ws@8.18.3", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg=="],

"lightningcss/detect-libc": ["detect-libc@2.1.2", "", {}, "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ=="],

"lmdb/node-addon-api": ["node-addon-api@6.1.0", "", {}, "sha512-+eawOlIgy680F0kBzPUNFhMZGtJ1YmqM6l4+Crf4IkImjYrO/mqPwRMh352g23uIaQKFItcQ64I7KMaJxHgAVA=="],
Expand Down
16 changes: 8 additions & 8 deletions web-transport/src/quinn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl Server {

/// A WebTransport Session, able to accept/create streams and send/recv datagrams.
///
/// The session can be cloned to create multiple handles.
/// The session can be cloned to create multiple handles, which is which no method is &mut.
/// The session will be closed with on drop.
#[derive(Clone, PartialEq, Eq)]
pub struct Session {
Expand All @@ -98,19 +98,19 @@ impl Session {
/// Block until the peer creates a new unidirectional stream.
///
/// Won't return None unless the connection is closed.
pub async fn accept_uni(&mut self) -> Result<RecvStream, Error> {
pub async fn accept_uni(&self) -> Result<RecvStream, Error> {
let stream = self.inner.accept_uni().await?;
Ok(RecvStream::new(stream))
}

/// Block until the peer creates a new bidirectional stream.
pub async fn accept_bi(&mut self) -> Result<(SendStream, RecvStream), Error> {
pub async fn accept_bi(&self) -> Result<(SendStream, RecvStream), Error> {
let (s, r) = self.inner.accept_bi().await?;
Ok((SendStream::new(s), RecvStream::new(r)))
}

/// Open a new bidirectional stream, which may block when there are too many concurrent streams.
pub async fn open_bi(&mut self) -> Result<(SendStream, RecvStream), Error> {
pub async fn open_bi(&self) -> Result<(SendStream, RecvStream), Error> {
Ok(self
.inner
.open_bi()
Expand All @@ -119,7 +119,7 @@ impl Session {
}

/// Open a new unidirectional stream, which may block when there are too many concurrent streams.
pub async fn open_uni(&mut self) -> Result<SendStream, Error> {
pub async fn open_uni(&self) -> Result<SendStream, Error> {
Ok(self.inner.open_uni().await.map(SendStream::new)?)
}

Expand All @@ -132,7 +132,7 @@ impl Session {
/// - Peer is not receiving datagrams.
/// - Peer has too many outstanding datagrams.
/// - ???
pub async fn send_datagram(&mut self, payload: Bytes) -> Result<(), Error> {
pub async fn send_datagram(&self, payload: Bytes) -> Result<(), Error> {
// NOTE: This is not async, but we need to make it async to match the wasm implementation.
Ok(self.inner.send_datagram(payload)?)
}
Expand All @@ -143,12 +143,12 @@ impl Session {
}

/// Receive a datagram over the network.
pub async fn recv_datagram(&mut self) -> Result<Bytes, Error> {
pub async fn recv_datagram(&self) -> Result<Bytes, Error> {
Ok(self.inner.read_datagram().await?)
}

/// Close the connection immediately with a code and reason.
pub fn close(&mut self, code: u32, reason: &str) {
pub fn close(&self, code: u32, reason: &str) {
self.inner.close(code, reason.as_bytes())
}

Expand Down
14 changes: 7 additions & 7 deletions web-transport/src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,27 +63,27 @@ impl Client {
pub struct Session(web_transport_wasm::Session);

impl Session {
pub async fn accept_uni(&mut self) -> Result<RecvStream, Error> {
pub async fn accept_uni(&self) -> Result<RecvStream, Error> {
let stream = self.0.accept_uni().await?;
Ok(RecvStream(stream))
}

pub async fn accept_bi(&mut self) -> Result<(SendStream, RecvStream), Error> {
pub async fn accept_bi(&self) -> Result<(SendStream, RecvStream), Error> {
let (s, r) = self.0.accept_bi().await?;
Ok((SendStream(s), RecvStream(r)))
}

pub async fn open_bi(&mut self) -> Result<(SendStream, RecvStream), Error> {
pub async fn open_bi(&self) -> Result<(SendStream, RecvStream), Error> {
let (s, r) = self.0.open_bi().await?;
Ok((SendStream(s), RecvStream(r)))
}

pub async fn open_uni(&mut self) -> Result<SendStream, Error> {
pub async fn open_uni(&self) -> Result<SendStream, Error> {
self.0.open_uni().await.map(SendStream)
}

/// Close the connection immediately
pub fn close(&mut self, code: u32, reason: &str) {
pub fn close(&self, code: u32, reason: &str) {
self.0.close(code, reason)
}

Expand All @@ -92,11 +92,11 @@ impl Session {
}

/// Send a datagram.
pub async fn send_datagram(&mut self, payload: Bytes) -> Result<(), Error> {
pub async fn send_datagram(&self, payload: Bytes) -> Result<(), Error> {
self.0.send_datagram(payload).await
}

pub async fn recv_datagram(&mut self) -> Result<Bytes, Error> {
pub async fn recv_datagram(&self) -> Result<Bytes, Error> {
self.0.recv_datagram().await
}

Expand Down