feat(052): runtime-neutral connector I/O - #248
Open
lxsaah wants to merge 16 commits into
Open
Conversation
…r enhanced connection handling
…cross multiple files
… for embassy adapter
…s for datagram handling
… Send future wrapper
…ared channel on std
…ent datagram handling
… update Makefile for MQTT checks
…rdize PLL configuration constants
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.
Implements wave A of design 052 — runtime-neutral connectors: the layer that lets an adapter own sockets, clocks and name resolution while a connector owns framing and protocol. A new runtime then costs one adapter crate and zero connector edits.
This PR is additive. Nothing consumes the new code on the live paths yet — the existing
tokio_*/embassy_*connector modules are untouched and still own every production path. Migrating them (and deleting ~4 130 lines) is wave B.What lands
aimdb-coresession::io—ByteStream,StreamDialer,StreamListener,Datagram,DatagramBinder,Delay,Framer;FramedConnection+FramingDialer/FramingListener;OneShot<T>aimdb-tokio-adapternetfeature —TokioNet::tcp/listen/udp,TokioDelay. Every future a plainasync fn, nounsafeaimdb-embassy-adapternetfeature —EmbassyNet::tcp/listen::<N>/udp,EmbassyUart,EmbassyDelay. All force-Sendfor these paths lives hereaimdb-knx-connectorneutral::connection_task— one task for both runtimes;TunnelIo::sendgains+ Send;embassy-sync/embassy-futureson stdaimdb-serial-connectorneutral— the crate reduced to a COBSFramer; byte sources come from the adaptersaimdb-tcp-connectortests/neutral_pool.rs— the accept-pool proofaimdb-mqtt-connectorTlsOptions::newrequires aSendRNG;TlsSlotbecomesOneShot. Crate now carries zerounsafe impls (was two)Design decisions worth review
The
Sendbound sits on each trait's return type, not at the use site. Generic connector code must produceSendfutures at the boxing boundary, and return-type notation is still experimental on the pinned 1.98 toolchain. A std impl writes a plainasync fnand the compiler discharges it; an Embassy impl returns the adapter's force-Sendnewtype.aimdb-core/src/session/io.rscarries a compile-time assertion, so dropping a bound fails in core rather than three crates away.The Embassy listener stores one pending accept per slot rather than rebuilding them.
TcpSocket::acceptis a synchronouslisten()plus a barepoll_fn, so dropping the future does not un-listen the socket — but re-enteringaccept()on a listening socket is an error, and theabort()that makes it re-enterable is what drops theLISTEN.tests/neutral_pool.rsholds both halves to real sockets, with a rebuild-and-cancel pool as a negative control that loses a SYN arriving between accepts.Datagram::local_addris part of the contract. Without it, unifying the KNX task would have silently downgraded every Tokio deployment to the NAT-style0.0.0.0:0HPAI that some gateways reject.unified_task_advertises_the_real_local_endpointreads the CONNECT_REQUEST off the wire and asserts the real bound address.embassy-syncandembassy-futuresare executor-independent despite the names — neither pulls an executor, andembassy-futureshas no dependencies at all. Both now back the KNX task on std.CriticalSectionRawMutexis the onlySyncraw mutexembassy-syncoffers, and it is a link-time obligation on std, sotokio-runtimeenablescritical-section/stditself andtests/shared_channel_on_std.rsproves the binary links.Deviations from the design doc
EmbassyUart::new(rx, tx), not::split— the caller has already split the UART; this joins the halves.aimdb-serial-connector'stokio-runtimenow depends onaimdb-tokio-adapter, so its byte source comes from the adapter on both runtimes instead of being duplicated. Recorded in that crate's CHANGELOG as an explicit reversal.TlsOptionsgate is on the connector'sembassy-tlspath, not the demo — see below.Incidental fixes
RUSTDOCFLAGS=-D warningsonmake doc, which CI already runs — so this cannot regress silently.make exampleswas broken and never run in CI.stm32-metapac21 renamed the RCC enum variants, so all five embedded examples failed to compile. Fixed, and all five now build forthumbv8m.main-none-eabihf— their actual board architecture — instead ofthumbv7em.thumbv8m.mainis pinned inrust-toolchain.tomland the devcontainer.aimdb-corewithconnector-session; it does now.Verification
Every commit was verified in isolation: unit + integration tests, clippy
-D warningson each feature configuration,thumbv7emcross-compilation, rustdoc, andcargo fmt --check.make examplespasses end to end. Acceptance criterion 1 holds — core cross-compiles with the new traits and still contains zerounsafe.The three remaining
unsafe impls in connector crates are all inaimdb-tcp-connector/src/embassy_transport.rs, the module wave B deletes.Not yet run: a full
make checkacross the branch. Per-crate runs can miss feature-unification effects, and this branch changed feature graphs in four crates — CI is the check.