Skip to content

feat(io,tls)!: require Splittable for AsyncStream#874

Merged
Berrysoft merged 18 commits intocompio-rs:masterfrom
Berrysoft:dev/async-stream-splittable
Apr 18, 2026
Merged

feat(io,tls)!: require Splittable for AsyncStream#874
Berrysoft merged 18 commits intocompio-rs:masterfrom
Berrysoft:dev/async-stream-splittable

Conversation

@Berrysoft
Copy link
Copy Markdown
Member

Previously we require for<'a> &'a S: AsyncRead + AsyncWrite to ensure that the inner stream is OK to be called read and write simultaneously, but it is not perfect. A user can still construct unsound code with it. Now we require Splittable directly for safety.

A new type CompatMaybeTlsStreamInner is also added to loose the type requirements. After this PR, I think I'll rewrite compio-ws to use it and make the websocket stream splittable directly without another compat type.

@Berrysoft Berrysoft requested a review from Copilot April 16, 2026 16:28
@Berrysoft Berrysoft self-assigned this Apr 16, 2026
@Berrysoft Berrysoft added package: io Related to compio-io package: tls Related to compio-tls labels Apr 16, 2026
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

This PR tightens I/O safety guarantees across TLS and WebSocket integration by requiring Splittable for streams that may be read and written concurrently (notably through compat::AsyncStream and TLS stream wrappers), and introduces a futures-util compatibility wrapper for MaybeTlsStream.

Changes:

  • Require util::Splittable (plus ReadHalf/WriteHalf bounds) for compio_io::compat::AsyncStream and for TLS/WebSocket stream generics that rely on concurrent read/write.
  • Update compio-tls stream types (TlsStream, MaybeTlsStream, rustls acceptor types) to use Splittable-based bounds instead of for<'a> &'a S: AsyncRead + AsyncWrite.
  • Add CompatMaybeTlsStream and MaybeTlsStream::into_compat() to provide futures_util::AsyncRead/AsyncWrite compatibility.

Reviewed changes

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

Show a summary per file
File Description
compio-ws/src/tls.rs Updates WebSocket TLS helpers to require Splittable and half bounds for safe duplex usage.
compio-tls/src/stream.rs Makes TlsStream require Splittable and expresses read/write capability via halves.
compio-tls/src/rtls.rs Applies Splittable + half bounds to rustls lazy acceptor/handshake wrapper types.
compio-tls/src/maybe.rs Makes MaybeTlsStream Splittable-based and adds CompatMaybeTlsStream + into_compat().
compio-tls/src/adapter.rs Updates TLS connector/acceptor APIs to require Splittable and half bounds.
compio-tls/Cargo.toml Makes futures-util non-optional to match unconditional usage.
compio-io/src/compat/async_stream.rs Reworks AsyncStream to require Splittable and internally split into read/write halves.

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

Comment thread compio-tls/src/adapter.rs Outdated
Comment thread compio-tls/src/adapter.rs Outdated
Comment thread compio-tls/src/rtls.rs Outdated
Comment thread compio-tls/src/rtls.rs Outdated
@Berrysoft Berrysoft requested a review from George-Miao April 16, 2026 16:39
@Berrysoft Berrysoft marked this pull request as draft April 16, 2026 18:00
@Berrysoft Berrysoft marked this pull request as draft April 16, 2026 18:00
@Berrysoft Berrysoft marked this pull request as ready for review April 16, 2026 18:34
@Berrysoft Berrysoft marked this pull request as draft April 16, 2026 19:53
@Berrysoft Berrysoft requested a review from Copilot April 16, 2026 19:53
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

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.


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

Comment thread compio-tls/src/stream.rs
Comment thread compio-tls/src/maybe.rs Outdated
Comment thread compio-tls/src/maybe.rs Outdated
Comment thread compio-tls/src/maybe.rs
Comment thread compio-tls/src/maybe.rs Outdated
Comment thread compio-tls/src/maybe.rs
@Berrysoft Berrysoft marked this pull request as ready for review April 17, 2026 04:17
Comment thread compio-io/src/compat/async_stream.rs Outdated
@Berrysoft Berrysoft added this to the v0.19 milestone Apr 17, 2026
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

@Berrysoft Berrysoft added this pull request to the merge queue Apr 18, 2026
Merged via the queue into compio-rs:master with commit 31f2c20 Apr 18, 2026
71 checks passed
@Berrysoft Berrysoft deleted the dev/async-stream-splittable branch April 18, 2026 03:15
@github-actions github-actions bot mentioned this pull request Apr 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: io Related to compio-io package: tls Related to compio-tls

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants