Skip to content

refactor(ws)!: futures compat#875

Merged
George-Miao merged 27 commits intocompio-rs:masterfrom
Berrysoft:refactor/ws-compat
Apr 19, 2026
Merged

refactor(ws)!: futures compat#875
George-Miao merged 27 commits intocompio-rs:masterfrom
Berrysoft:refactor/ws-compat

Conversation

@Berrysoft
Copy link
Copy Markdown
Member

@Berrysoft Berrysoft commented Apr 16, 2026

This PR uses async-tungstenite to simplify the code, and provide first-class futures compat.

@Berrysoft Berrysoft added refactor Refactoring existing code package: ws Related to compio-ws labels Apr 16, 2026
@Berrysoft Berrysoft self-assigned this Apr 16, 2026
@Berrysoft Berrysoft added this to the v0.19 milestone Apr 16, 2026
@Berrysoft Berrysoft force-pushed the refactor/ws-compat branch from be56aa1 to e7c447b Compare April 16, 2026 19:28
@Berrysoft Berrysoft force-pushed the refactor/ws-compat branch from e7c447b to 8ba414b Compare April 17, 2026 16:42
@Berrysoft Berrysoft marked this pull request as ready for review April 18, 2026 03:39
@Berrysoft Berrysoft requested a review from Copilot April 18, 2026 03:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors compio-ws to build on async-tungstenite instead of manually driving tungstenite, aiming to provide first-class futures Sink/Stream compatibility and simplify buffering/handshake logic across plain and TLS connections.

Changes:

  • Replaces the custom SyncStream-based WebSocket implementation (and the separate compat wrapper) with an async_tungstenite::WebSocketStream-backed WebSocketStream that implements futures_util::Sink/Stream.
  • Reworks TLS helpers to wrap streams via compio_io::compat::AsyncStream and adds *_compat entrypoints in compio-tls for passing pre-configured AsyncStreams.
  • Updates features/examples/tests to match the new API and removes the old io-compat feature path for websockets.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
compio/Cargo.toml Adjusts feature wiring for io-compat/tls now that compio-ws changes its compat/TLS surface.
compio-ws/Cargo.toml Adds async-tungstenite, reshapes features (introduces tls), updates example gating.
compio-ws/src/lib.rs Major refactor: new WebSocketStream built on async-tungstenite with Sink/Stream impls.
compio-ws/src/tls.rs Updates TLS wrapping to use AsyncStream limits and new connector APIs; changes return types.
compio-ws/tests/websocket.rs Updates compat test to use direct Sink/Stream behavior without the old compat wrapper.
compio-ws/examples/ws_split.rs Switches split example to ws.split() on the native Sink/Stream impl.
compio-ws/src/compat.rs Removes the old custom futures-compat wrapper implementation.
compio-tls/src/maybe.rs Adds new_plain_compat(AsyncStream<...>) constructor.
compio-tls/src/adapter.rs Adds connect_compat/accept_compat to accept pre-configured AsyncStream.
compio-io/src/compat/async_stream.rs Adds AsyncStream::with_limits constructor.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread compio-ws/src/lib.rs
Comment thread compio-ws/src/lib.rs
Comment thread compio-ws/src/lib.rs
Comment thread compio-ws/src/lib.rs Outdated
Comment thread compio-ws/src/lib.rs
Comment thread compio-ws/src/tls.rs
Comment thread compio-ws/Cargo.toml
@Berrysoft Berrysoft requested a review from George-Miao April 18, 2026 07:54
@George-Miao George-Miao changed the title refactor(ws): futures compat refactor(ws)!: futures compat Apr 18, 2026
Comment thread compio-ws/Cargo.toml
@Berrysoft Berrysoft requested a review from George-Miao April 18, 2026 13:19
@George-Miao George-Miao enabled auto-merge (squash) April 18, 2026 15:48
Copy link
Copy Markdown
Member

@George-Miao George-Miao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@George-Miao George-Miao merged commit 30c2235 into compio-rs:master Apr 19, 2026
71 checks passed
@github-actions github-actions bot mentioned this pull request Apr 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change package: ws Related to compio-ws refactor Refactoring existing code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants