Feat/platform agnostic tcp connectors - #250
Open
lxsaah wants to merge 4 commits into
Open
Conversation
…connectors with length-prefix framing
… listener for improved framing support
- Updated `Cargo.toml` and `Cargo.lock` to remove unnecessary dependencies and streamline the project. - Modified `endpoint.rs` to utilize the new `framed_dialer_at` function for TCP connections. - Enhanced `connector.rs` with a new `split_host_port` function to handle host:port parsing and added a `framed_dialer_at` function for cleaner dialing. - Removed the `embassy_transport.rs` and `tokio_transport.rs` files as they are superseded by the new connector implementation. - Updated `lib.rs` to reflect the changes in module structure and removed deprecated transport modules. - Adjusted example in `tcp_demo.rs` to align with the new dialing approach.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Wave B of design 052, first connector: the TCP connector moves onto the runtime-neutral I/O layer wave A added. The adapter owns the socket; this crate contributes only length-prefix framing.
The crate goes from 1 428 lines to 385.
Commits
TcpClient/TcpServeroverStreamDialer/StreamListener; the runtime modules staytcp_demoonto the adapter transports; the old modules become unreferencedtokio_transport.rs(302) +embassy_transport.rs(591), and the dependencies they neededSplit that way so the deletion diff is purely subtractive and every commit is green on its own.
Result
unsafe impls in any connector crate — the three here were the last outside the adapters (acceptance 2).tokio,embassy-net,embassy-futuresorembedded-io-asyncin the library graph — checked withcargo tree, not just by deleting files (acceptance 3).embassy-netremains test-only for the loopback harness.Breaking
lib.rs's wholeall(tokio-runtime, embassy-runtime)aliasing block is gone —TokioTcpServer/EmbassyTcpServer,TokioTcpConnection/EmbassyTcpConnectionand friends existed only to disambiguate two implementations of the same concept. One implementation, one name:TcpServer::newnow takes an already-bound listener rather than a bind string, so the adapter does the binding.Worth a look in review
Framer::encodeis infallible, but length-prefix encoding is not. An oversized frame is dropped whole rather than written half-encoded — a length prefix with no payload behind it would desync the peer permanently, and unlike COBS there is no delimiter to resync on.TcpServerholds its listener in aOneShot, taken on first poll rather than at call time. Abuild()future dropped before being polled must leave the listener in place, or a later build fails having never served anything.an_unpolled_build_leaves_the_listener_in_placepins it.split_host_portfixes a bug it inherited. Two call sites had grown private copies usingrsplit_once(':'), which mangles a bracketed IPv6 host with no port — the formaimdb-client's own error message documents. Hoisted into the connector with five tests; brackets are now stripped, which is what both adapters actually resolve.Verification
make checkclean: 2 031 tests, 0 failures, all stages.aimdb-clientneeded a fix — it used the deletedTcpDialerthrough the crate-root re-export, which a module-path grep does not see.