refactor(io,tls,ws)!: use pin-project-lite#720
Merged
Berrysoft merged 8 commits intocompio-rs:masterfrom Mar 5, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the compio-io compat adapter and downstream TLS/WebSocket integration to use pin-project-lite-based pinning, adjusting rustls stream types to be pinned and tightening various generic bounds accordingly.
Changes:
- Refactor
compio_io::compat::AsyncStreamto usepin_project_lite+PhantomPinnedand update call sites to pin the stream before usingfutures_utilextension traits. - Update rustls integration to wrap compat streams as
Pin<Box<AsyncStream<_>>>(and adjust relatedFromimpls / acceptor types). - Add
Unpinbounds to several public APIs (TlsConnector,TlsAcceptor, websocket TLS helpers) to satisfy the new compat adapter constraints.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| compio-ws/src/tls.rs | Tightens stream bounds to Unpin for TLS/plain wrapping to match updated TLS connector constraints. |
| compio-tls/src/stream.rs | Changes rustls inner stream type to Pin<Box<AsyncStream<_>>> and tightens TlsStream trait impl bounds. |
| compio-tls/src/rtls.rs | Updates rustls lazy acceptor/handshake wrapper types to use pinned compat streams and adds Unpin bounds. |
| compio-tls/src/adapter.rs | Pins compat streams for rustls connect/accept and adds Unpin to public generic bounds. |
| compio-io/src/compat/async_stream.rs | Switches to pin-project-lite, makes AsyncStream !Unpin, and reworks internal pin/borrow handling. |
| compio-io/tests/compat.rs | Updates tests to pin AsyncStream before using futures_util extension traits. |
| compio-io/Cargo.toml | Adds optional pin-project-lite dependency and wires it into the compat feature. |
Comments suppressed due to low confidence (2)
compio-tls/src/adapter.rs:89
TlsConnector::connectnow requiresS: Unpineven though only therustlsbranch needs pinning (native-tls / py-dynamic-openssl paths don’t inherently requireUnpin). This is a public API tightening that can break downstream users with!Unpinstreams.
If possible, keep the original bound and add Unpin only when the rustls feature is enabled/used (e.g., via a rustls-specific helper method, a cfg-gated impl, or by adjusting compat::AsyncStream so it doesn’t require S: Unpin).
pub async fn connect<S: AsyncRead + AsyncWrite + Unpin + 'static>(
&self,
domain: &str,
stream: S,
) -> io::Result<TlsStream<S>> {
compio-tls/src/stream.rs:133
TlsStream<S>’sAsyncRead/AsyncWriteimpls now requireS: Unpin, which is a public behavior change (some downstreamStypes that were previously supported may no longer compile). If this is only needed for the rustls backend, consider constrainingUnpinto the rustls-specific path/types rather than the blanket impl bounds, or document this as a breaking change.
impl<S: AsyncRead + AsyncWrite + Unpin + 'static> AsyncRead for TlsStream<S> {
async fn read<B: IoBufMut>(&mut self, mut buf: B) -> BufResult<usize, B> {
let slice = buf.as_uninit();
slice.fill(MaybeUninit::new(0));
// SAFETY: The memory has been initialized
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I will try TAIT after this PR.