Skip to content

feat(tls): futures compat#868

Merged
Berrysoft merged 8 commits intocompio-rs:masterfrom
Berrysoft:dev/tls-compat
Apr 16, 2026
Merged

feat(tls): futures compat#868
Berrysoft merged 8 commits intocompio-rs:masterfrom
Berrysoft:dev/tls-compat

Conversation

@Berrysoft
Copy link
Copy Markdown
Member

This PR ports the code of tokio-native-tls for the native-tls and py-openssl backend. There might be some redundant code...

As it is built on top of AsyncStream, the TlsStream is futures-compatible now. The downside is that it will always require Box::pin.

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 refactors compio-tls’s TlsStream implementation to be futures-compatible by adapting TLS backends (native-tls and py-openssl) to futures_util::AsyncRead/AsyncWrite via compio_io::compat::AsyncStream, and routing compio’s async IO through those futures traits.

Changes:

  • Replace SyncStream-based native-tls and py-openssl handling with futures-compatible TLS stream wrappers built around AsyncStream + Pin<Box<...>>.
  • Add new native backend module ported from tokio-native-tls, and heavily rework the py-openssl backend to use a similar polling/context-pointer approach.
  • Update connector/acceptor implementations and feature flags to depend on futures-util where required.

Reviewed changes

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

Show a summary per file
File Description
compio-tls/src/stream.rs Reworks TlsStream to delegate IO through futures AsyncRead/AsyncWrite and adds vectored-write support.
compio-tls/src/py_ossl.rs Replaces the previous drive-loop implementation with a futures-style polling adapter around SslStream.
compio-tls/src/native.rs New native-tls futures adapter ported from tokio-native-tls.
compio-tls/src/adapter.rs Updates connector/acceptor to construct pinned AsyncStream and use the new backend wrappers.
compio-tls/src/maybe.rs Moves negotiated_alpn into a bounded impl block consistent with new TlsStream bounds.
compio-tls/src/lib.rs Wires in the new native module behind the native-tls feature.
compio-tls/Cargo.toml Adds futures-util as a feature dependency for native-tls and py-openssl backends.

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

Comment thread compio-tls/src/compat/native.rs
Comment thread compio-tls/src/compat/py_ossl.rs
Comment thread compio-tls/src/stream.rs
Comment thread compio-tls/src/stream.rs
Comment thread compio-tls/src/compat/py_ossl.rs
Comment thread compio-tls/src/lib.rs
@Berrysoft Berrysoft marked this pull request as draft April 14, 2026 18:20
@Berrysoft Berrysoft marked this pull request as ready for review April 15, 2026 08:40
@Berrysoft Berrysoft requested a review from George-Miao April 15, 2026 08:40
@Berrysoft Berrysoft added the package: tls Related to compio-tls label Apr 16, 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

@fantix
Copy link
Copy Markdown
Contributor

fantix commented Apr 16, 2026

LGTM and go ahead with merging and all, I'll try adapting my kTLS-compat draft PR this weekend and submit tweaks if needed.

@Berrysoft Berrysoft added this pull request to the merge queue Apr 16, 2026
Merged via the queue into compio-rs:master with commit 4f37361 Apr 16, 2026
68 checks passed
@Berrysoft Berrysoft deleted the dev/tls-compat branch April 16, 2026 15:54
@github-actions github-actions bot mentioned this pull request Apr 16, 2026
@Berrysoft Berrysoft added this to the v0.19 milestone Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: tls Related to compio-tls

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants