diff --git a/bun.lock b/bun.lock index 9e1cf7a..2971419 100644 --- a/bun.lock +++ b/bun.lock @@ -22,7 +22,6 @@ "rimraf": "^6.0.1", "tsx": "^4.20.5", "typescript": "^5.9.2", - "ws": "^8.16.0", }, }, }, @@ -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=="], diff --git a/web-transport/src/quinn.rs b/web-transport/src/quinn.rs index 7bb92e8..aff2ef5 100644 --- a/web-transport/src/quinn.rs +++ b/web-transport/src/quinn.rs @@ -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 { @@ -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 { + pub async fn accept_uni(&self) -> Result { 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() @@ -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 { + pub async fn open_uni(&self) -> Result { Ok(self.inner.open_uni().await.map(SendStream::new)?) } @@ -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)?) } @@ -143,12 +143,12 @@ impl Session { } /// Receive a datagram over the network. - pub async fn recv_datagram(&mut self) -> Result { + pub async fn recv_datagram(&self) -> Result { 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()) } diff --git a/web-transport/src/wasm.rs b/web-transport/src/wasm.rs index 81cd42f..b9c999d 100644 --- a/web-transport/src/wasm.rs +++ b/web-transport/src/wasm.rs @@ -63,27 +63,27 @@ impl Client { pub struct Session(web_transport_wasm::Session); impl Session { - pub async fn accept_uni(&mut self) -> Result { + pub async fn accept_uni(&self) -> Result { 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 { + pub async fn open_uni(&self) -> Result { 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) } @@ -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 { + pub async fn recv_datagram(&self) -> Result { self.0.recv_datagram().await }