Skip to content

feat(052): runtime-neutral serial connector - #251

Open
lxsaah wants to merge 3 commits into
mainfrom
feat/platform-agnostic-serial-connector
Open

feat(052): runtime-neutral serial connector#251
lxsaah wants to merge 3 commits into
mainfrom
feat/platform-agnostic-serial-connector

Conversation

@lxsaah

@lxsaah lxsaah commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Wave B of design 052, second connector. The adapter owns the byte source; this crate contributes only COBS framing.

Same add → migrate → delete shape as the TCP connector (#250), so the deletion commit is purely subtractive and every commit is green on its own.

Result

One path for both runtimes. tokio_transport.rs (312) and embassy_transport.rs (237) are gone, along with the whole all(tokio-runtime, embassy-runtime) alias set — those names existed only to disambiguate two implementations of the same thing.

_test-tokio is removed too. It existed solely to add the adapter for tests; tokio-runtime carries it now, so the alias had nothing left to gate.

Breaking

  • SerialServer::new takes an adapter byte stream — EmbassyUart::new(rx, tx) or TokioByteStream(port) — instead of (path, baud) or split UART halves. The application opens the device, which is where device ownership belongs.
  • SerialDialerSerialPortDialer. SerialListener, TokioSerialConnection and the Tokio*/Embassy* aliases are gone.
  • SerialClient::new(stream) serves a moved-in stream once; SerialClient::over_port(path, baud) reopens and redials on a host.

Updated in-tree: three embassy demos, aimdb-client's serial arm, and serial_demo.

Worth a look in review

A UART is point-to-point, so there is no accept loop. OneShotDialer hands the connection out once then errors — nothing to redial. OneShotListener hands it out once then parks forever, because serve loops on accept and an error would spin it. Both are neutral (built on core's OneShot, no unsafe), replacing the Embassy adapter's SendFutureWrapper-carrying versions.

FramingDialer is deliberately unused here. It exists to attach a host/port to a StreamDialer; serial has neither — the device path is the dialer's own state and baud is configuration. FramedConnection is used directly.

tokio-serial stays in the connector, not the adapter: opening a tty is not a runtime concern (design §3.3).

SerialServer::build takes its stream on first poll, not at call time — a build() future dropped before being polled must leave the stream in place. Covered by the_server_guards_its_moved_in_stream.

Notes

Branched from main, not from #250. Both touch aimdb-client/src/endpoint.rs; whichever merges second needs a rebase there.

@lxsaah lxsaah changed the title feat(052): runtime-neutral serial connector docs(serial-connector): changelog for the runtime-neutral migration Sep 6, 2026
@lxsaah
lxsaah force-pushed the feat/platform-agnostic-serial-connector branch from 17f2f55 to fa71346 Compare September 6, 2026 09:17
@lxsaah lxsaah changed the title docs(serial-connector): changelog for the runtime-neutral migration feat(052): runtime-neutral serial connector Sep 6, 2026
lxsaah and others added 3 commits September 6, 2026 09:28
…encies

- Updated the Makefile to replace the `_test-tokio` feature with `tokio-runtime` for testing and clippy commands.
- Renamed `SerialDialer` to `SerialPortDialer` in the endpoint resolution to reflect the new naming convention.
- Removed the `_test-tokio` feature from the `Cargo.toml` of `aimdb-serial-connector` and updated dependencies accordingly.
- Refactored the `serial_demo` example to use the new `tokio-runtime` feature instead of `_test-tokio`.
- Deleted the `embassy_transport.rs` file and moved relevant functionality to the `connector` module.
- Updated tests to use the new `OneShotDialer` and `OneShotListener` from the `connector` module.
- Modified the `main.rs` files in various examples to utilize `EmbassyUart` for serial connections.
The Unreleased entry still promised `_test-tokio` "remains as an alias",
which B5 made false by removing it. Replaces that with the breaking
surface: `SerialServer::new` takes an adapter byte stream, the two
transport modules and the `Tokio*`/`Embassy*` aliases are gone, and
`SerialDialer` is now `SerialPortDialer`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@lxsaah
lxsaah force-pushed the feat/platform-agnostic-serial-connector branch from fa71346 to 2a84a12 Compare September 6, 2026 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant