Skip to content

Add a tokio transport and socket manager#79

Closed
JustinKovacich wants to merge 13 commits into
feature/transport_socket_traitfrom
feature/tokio_transport_and_socket_manager
Closed

Add a tokio transport and socket manager#79
JustinKovacich wants to merge 13 commits into
feature/transport_socket_traitfrom
feature/tokio_transport_and_socket_manager

Conversation

@JustinKovacich

@JustinKovacich JustinKovacich commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Encapsulate socket2 usage behind the new TransportFactory / TransportSocket / Timer traits (introduced in #78) and switch client/server code paths to speak to those traits instead of reaching for socket2 directly. socket2 is still a dependency of this crate — it now lives in the new src/tokio_transport.rs module (gated behind client/server), which is the only place that still constructs raw socket2::Socket for bind-time options (SO_REUSEADDR, multicast interface, multicast loop).

This PR is part of a chain. Prev: #78. Next: #80.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 introduces a Tokio-based UDP transport backend that implements the new executor-agnostic transport traits, and refactors the client socket manager to bind sockets through that abstraction (reducing direct socket2 usage in client code).

Changes:

  • Add TokioTransport/TokioSocket/TokioTimer as a client/server-gated default std backend for transport traits.
  • Derive thiserror::Error + add display messages for IoErrorKind and TransportError.
  • Refactor client::SocketManager binds to go through TransportFactory, making binding async and injectable for tests/alternate factories.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/transport.rs Adds thiserror::Error derives + display strings for portable transport error enums.
src/tokio_transport.rs New Tokio+socket2 transport backend implementing TransportFactory, TransportSocket, and Timer.
src/lib.rs Exposes the tokio transport module and re-exports its types under client/server.
src/client/socket_manager.rs Switches bind paths to TransportFactory/TransportSocket; adds injectable bind variants and updates I/O loop types accordingly.
src/client/inner.rs Updates discovery/unicast bind helpers to async to match new socket manager API.
src/client/error.rs Adds Error::Transport(TransportError) to surface backend errors.

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

Comment thread src/tokio_transport.rs Outdated
Comment thread src/client/error.rs Outdated
Comment thread src/lib.rs Outdated
@JustinKovacich JustinKovacich mentioned this pull request Apr 23, 2026
@JustinKovacich JustinKovacich self-assigned this Apr 23, 2026
@JustinKovacich JustinKovacich added documentation Improvements or additions to documentation enhancement New feature or request labels Apr 23, 2026
JustinKovacich added a commit that referenced this pull request Apr 23, 2026
Addresses three Copilot review comments.

1. tokio_transport: apply `multicast_loop_v4` unconditionally.
   The previous `if options.multicast_loop_v4 { set_multicast_loop_v4(true) }`
   only set the flag when the caller requested it ON; when OFF the socket
   kept the OS default (loopback ENABLED on Linux), diverging from the
   pre-trait code path that always called IP_MULTICAST_LOOP with the
   requested value. Fix: call `set_multicast_loop_v4(options.multicast_loop_v4)`
   every bind. A new `pub(crate) TokioSocket::multicast_loop_v4()` wraps
   `tokio::net::UdpSocket::multicast_loop_v4()` so tests (and future field
   debugging) can read the flag back. Covered by
   `multicast_loop_v4_option_propagates_in_both_directions`, which binds
   two sockets (false, true) and asserts the kernel reports the requested
   value for each.

2. client::Error::Transport: switch from `{0:?}` to `#[error(transparent)]`.
   The debug-format template was leaking variant names and struct-like
   debug output into user-facing error messages. Chose `transparent` over
   the prefixed `"transport error: {0}"` form for consistency with the
   three existing `#[error(transparent)]` variants on the same enum
   (`Protocol`, `Io`, `E2e`) — they all delegate fully to their inner
   Display. The `TransportError` Display impls already read as complete
   sentences ("address in use", "unsupported transport operation",
   "transport i/o: ..."), so the extra prefix would be noise. Covered by
   `transport_variant_displays_via_inner_display_not_debug`, which asserts
   the Display output contains no debug artifacts (`{`, `}`, `"`) and
   equals the inner `TransportError`'s Display verbatim.

3. transport / lib module docs: update the "no implementations ship"
   language. The TokioTransport / TokioSocket / TokioTimer backend now
   ships under the `client` / `server` features; the stale note in the
   transport module's `# Status` section and the short description next
   to `pub mod transport;` in lib.rs now point at the default backend.
   Docs-only; `cargo test --doc --all-features` passes.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@JustinKovacich JustinKovacich requested a review from Copilot April 23, 2026 17:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Introduces a default std + tokio transport backend implementing the crate’s new transport traits, and refactors the client socket manager to bind sockets through this abstraction (reducing direct socket setup logic in client code).

Changes:

  • Add tokio_transport module providing TokioTransport, TokioSocket, and TokioTimer implementations of the transport traits.
  • Refactor client::SocketManager and client::Inner bind paths to use TransportFactory/TransportSocket (and make binding async).
  • Improve transport/error ergonomics by giving IoErrorKind/TransportError Display via thiserror, and adding client::Error::Transport.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/transport.rs Updates transport docs and adds thiserror derives for transport error enums.
src/tokio_transport.rs New default tokio backend implementing TransportFactory, TransportSocket, and Timer + tests.
src/lib.rs Exposes and re-exports the tokio transport module/types behind client/server features.
src/client/socket_manager.rs Reworks socket binding to go through TokioTransport / TransportFactory; adjusts send/recv loop to trait-based I/O.
src/client/inner.rs Updates discovery/unicast bind flows to await the now-async socket binds.
src/client/error.rs Adds Error::Transport variant and test ensuring user-facing formatting uses Display.

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

Comment thread src/transport.rs Outdated
Comment thread src/tokio_transport.rs Outdated
Comment thread src/tokio_transport.rs Outdated
JustinKovacich added a commit that referenced this pull request Apr 23, 2026
Round-2 Copilot feedback on PR #79:

- src/tokio_transport.rs:129 recv_from: `tokio::net::UdpSocket::
  recv_from` silently truncates when the caller's buf is smaller
  than the datagram — it does not expose a truncation flag. The
  `ReceivedDatagram::truncated` field therefore always reports
  `false` on the Tokio backend. Reliable truncation detection would
  require a libc + unsafe `recvmsg`/MSG_TRUNC path, deferred to the
  phase 10+ bare-metal refactor. Added a precise in-line comment
  naming the platform limitation so callers don't mis-trust the
  field.

- src/tokio_transport.rs:213 map_io_error: the post-mapping logging
  previously unconditionally used `warn!` for every I/O error,
  which turned common steady-state conditions (TimedOut,
  Interrupted, ConnectionRefused during transient outages) into
  warning noise that can drown out actionable signal. Triaged by
  kind: common-path kinds drop to `debug!`; unexpected /
  misconfiguration-indicating kinds (PermissionDenied, AddrInUse,
  NetworkUnreachable, fallback Other) stay at `warn!`. Comment
  explains the rationale.

- src/transport.rs module docs: the `crate::tokio_transport::*`
  intra-doc links broke under default-feature rustdoc builds
  (the `tokio_transport` module is gated to `client`/`server`).
  Same resolution as the PR #83 intra-doc fixes in ee305e0:
  render the paths as code literals and add an inline note that
  the module requires those features. Keeps the information,
  drops the link.

No new behavior paths introduced — logging changes + docs only.
Existing tokio_transport test suite (6/6) still passes.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@JustinKovacich JustinKovacich requested a review from Copilot April 24, 2026 15:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 introduces a default std + tokio transport backend and starts migrating the client socket binding path to the new transport abstractions, reducing direct socket setup logic in client code.

Changes:

  • Add tokio_transport module implementing TransportFactory/TransportSocket/Timer using tokio::net::UdpSocket + socket2 for bind-time options.
  • Update transport docs and errors (IoErrorKind, TransportError) to provide Display/Error messages via thiserror.
  • Refactor client SocketManager/Inner socket binding to go through TransportFactory (defaulting to TokioTransport) and make bind APIs async; adjust tests accordingly.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/transport.rs Updates module docs and adds thiserror-based Display/Error impls for transport error enums.
src/tokio_transport.rs New tokio-based transport implementation (bind options via socket2), plus tests for bind/send/recv/options/error mapping.
src/lib.rs Exposes tokio_transport behind client/server and re-exports TokioTransport/TokioSocket/TokioTimer.
src/client/socket_manager.rs Reworks binding to use TransportFactory + SocketOptions, makes bind async, updates I/O loop to use TransportSocket.
src/client/inner.rs Adjusts discovery/unicast binding helpers and call sites to await the new async bind APIs.
src/client/error.rs Adds Error::Transport with transparent display and a regression test for formatting.

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

Comment thread src/client/socket_manager.rs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 introduces a default std + tokio transport backend implementing the crate’s new transport traits, and updates the client socket manager to bind sockets via the transport abstraction (instead of constructing sockets directly).

Changes:

  • Add tokio_transport module (TokioTransport, TokioSocket, TokioTimer) implementing transport traits and re-export it from the crate root under client/server.
  • Update transport error enums to implement Display/Error via thiserror for cleaner user-facing errors.
  • Refactor client::SocketManager binding paths to use TransportFactory/TransportSocket and make relevant bind methods async; update client inner loop accordingly.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/transport.rs Updates module docs to reflect shipped tokio backend; adds thiserror derives + Display messages for transport error enums.
src/tokio_transport.rs Adds the tokio backend implementation (socket binding via socket2, UDP I/O via tokio::net::UdpSocket, plus mapping/logging/tests).
src/lib.rs Exposes tokio_transport module and re-exports tokio transport types when client/server is enabled.
src/client/socket_manager.rs Switches socket binding to use the transport traits and TokioTransport; adjusts receive/send loop to use ReceivedDatagram.
src/client/inner.rs Updates discovery/unicast bind paths to await the now-async socket manager binding calls.
src/client/error.rs Adds a Transport error variant (transparent) and a regression test for Display formatting.

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

Comment thread src/client/socket_manager.rs
Comment thread src/tokio_transport.rs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a built-in Tokio + socket2 transport backend that implements the new executor-agnostic transport traits, and updates client plumbing to use the transport abstraction rather than constructing socket2::Socket directly.

Changes:

  • Add tokio_transport module (TokioTransport/TokioSocket/TokioTimer) with option-aware binding, error mapping, and unit tests.
  • Enhance transport error types to implement Display/Error via thiserror, and update transport module docs to reflect the shipped default backend.
  • Refactor client socket binding/loops to bind via TransportFactory/TransportSocket, making bind paths async and surfacing transport errors via a new client::Error::Transport.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/transport.rs Updates transport docs and derives thiserror::Error for transport error enums.
src/tokio_transport.rs Introduces Tokio + socket2 transport implementation plus tests and I/O error mapping.
src/lib.rs Exposes the new tokio_transport module and re-exports TokioTransport/TokioSocket/TokioTimer behind client/server.
src/client/socket_manager.rs Switches socket binding to TransportFactory, updates I/O loop to consume ReceivedDatagram, and makes bind APIs async.
src/client/inner.rs Adapts discovery/unicast binding to async socket manager APIs.
src/client/error.rs Adds Error::Transport(TransportError) and a regression test for Display formatting.

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

Comment thread src/tokio_transport.rs Outdated
Comment thread src/client/socket_manager.rs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 introduces a built-in Tokio+socket2 transport backend that implements the crate’s executor-agnostic transport traits, and refactors client socket binding/I/O to use that transport abstraction instead of constructing socket2::Socket directly.

Changes:

  • Add src/tokio_transport.rs implementing TransportFactory/TransportSocket/Timer via socket2 + tokio::net::UdpSocket, with error mapping and unit tests.
  • Update client socket management to bind via TransportFactory (defaulting to TokioTransport) and propagate transport-layer errors via a new client::Error::Transport variant.
  • Improve transport error ergonomics by adding Display via thiserror to IoErrorKind/TransportError, and update docs/reexports accordingly.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/transport.rs Updates transport docs and adds thiserror::Error + Display strings for transport error enums.
src/tokio_transport.rs New Tokio+socket2 backend providing default implementations + tests and error mapping.
src/lib.rs Exposes the new tokio_transport module and reexports TokioTransport/TokioSocket/TokioTimer under client/server.
src/client/socket_manager.rs Refactors bind paths to use TransportFactory/TransportSocket, makes binds async, and adjusts I/O loop to consume ReceivedDatagram.
src/client/inner.rs Updates discovery/unicast bind flows to await the new async socket-manager bind APIs.
src/client/error.rs Adds Error::Transport(#[from] TransportError) and a regression test for Display output.

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

Comment thread src/client/socket_manager.rs Outdated
Comment thread src/client/socket_manager.rs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 introduces a default std + tokio transport backend and refactors the client-side socket management to use the new transport abstractions instead of reaching for socket2 directly, aligning the crate with the transport traits introduced in #78.

Changes:

  • Add tokio_transport module implementing TransportFactory / TransportSocket / Timer using socket2 for bind-time options and tokio::net::UdpSocket for async I/O.
  • Update transport-layer errors to implement Display/Error via thiserror and refresh module-level docs to reflect the shipped default backend.
  • Refactor client SocketManager (and Inner bind paths/tests) to bind sockets via TransportFactory and operate on TransportSocket-provided I/O.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/transport.rs Updates transport docs and adds thiserror-based error messages for portable transport errors.
src/tokio_transport.rs New default tokio+socket2 backend implementing the transport traits, plus backend-focused tests.
src/lib.rs Exposes tokio_transport behind client/server and re-exports the default backend types.
src/client/socket_manager.rs Switches binding/I/O to TransportFactory/TransportSocket, adds transport-injection entry points, updates tests.
src/client/inner.rs Makes discovery/unicast bind paths async to accommodate async transport binding.
src/client/error.rs Introduces Error::Transport as a transparent wrapper around TransportError with regression test.

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

Comment thread src/client/socket_manager.rs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 completes the next step in the transport abstraction rollout by adding a built-in std + tokio backend (implemented via socket2 at bind-time) and migrating the client socket manager to use the TransportFactory / TransportSocket traits rather than constructing socket2::Socket directly.

Changes:

  • Add src/tokio_transport.rs implementing the transport traits (TokioTransport, TokioSocket, TokioTimer) plus unit tests.
  • Update transport/docs and crate exports to expose the default tokio backend behind client/server.
  • Refactor client SocketManager bind paths to go through TransportFactory and make bind operations async; propagate the async changes into client::Inner and tests; add Error::Transport.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/transport.rs Updates module docs and adds Display/Error impls for transport error enums.
src/tokio_transport.rs New default tokio+socket2 transport backend with error mapping + tests.
src/lib.rs Exposes tokio_transport module and re-exports tokio transport types when client/server are enabled.
src/client/socket_manager.rs Migrates binds to TransportFactory, updates socket loop to consume ReceivedDatagram, and adjusts tests for async binds.
src/client/inner.rs Propagates async bind changes into the client control loop and tests.
src/client/error.rs Adds Error::Transport and a regression test for display formatting.

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

@JustinKovacich JustinKovacich marked this pull request as ready for review April 24, 2026 22:36
@JustinKovacich JustinKovacich force-pushed the feature/transport_socket_trait branch from 62bce46 to 756f4b2 Compare April 25, 2026 00:32
JustinKovacich and others added 13 commits April 24, 2026 20:34
…current client/server code, gated behind client and server
Addresses three Copilot review comments.

1. tokio_transport: apply `multicast_loop_v4` unconditionally.
   The previous `if options.multicast_loop_v4 { set_multicast_loop_v4(true) }`
   only set the flag when the caller requested it ON; when OFF the socket
   kept the OS default (loopback ENABLED on Linux), diverging from the
   pre-trait code path that always called IP_MULTICAST_LOOP with the
   requested value. Fix: call `set_multicast_loop_v4(options.multicast_loop_v4)`
   every bind. A new `pub(crate) TokioSocket::multicast_loop_v4()` wraps
   `tokio::net::UdpSocket::multicast_loop_v4()` so tests (and future field
   debugging) can read the flag back. Covered by
   `multicast_loop_v4_option_propagates_in_both_directions`, which binds
   two sockets (false, true) and asserts the kernel reports the requested
   value for each.

2. client::Error::Transport: switch from `{0:?}` to `#[error(transparent)]`.
   The debug-format template was leaking variant names and struct-like
   debug output into user-facing error messages. Chose `transparent` over
   the prefixed `"transport error: {0}"` form for consistency with the
   three existing `#[error(transparent)]` variants on the same enum
   (`Protocol`, `Io`, `E2e`) — they all delegate fully to their inner
   Display. The `TransportError` Display impls already read as complete
   sentences ("address in use", "unsupported transport operation",
   "transport i/o: ..."), so the extra prefix would be noise. Covered by
   `transport_variant_displays_via_inner_display_not_debug`, which asserts
   the Display output contains no debug artifacts (`{`, `}`, `"`) and
   equals the inner `TransportError`'s Display verbatim.

3. transport / lib module docs: update the "no implementations ship"
   language. The TokioTransport / TokioSocket / TokioTimer backend now
   ships under the `client` / `server` features; the stale note in the
   transport module's `# Status` section and the short description next
   to `pub mod transport;` in lib.rs now point at the default backend.
   Docs-only; `cargo test --doc --all-features` passes.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Round-2 Copilot feedback on PR #79:

- src/tokio_transport.rs:129 recv_from: `tokio::net::UdpSocket::
  recv_from` silently truncates when the caller's buf is smaller
  than the datagram — it does not expose a truncation flag. The
  `ReceivedDatagram::truncated` field therefore always reports
  `false` on the Tokio backend. Reliable truncation detection would
  require a libc + unsafe `recvmsg`/MSG_TRUNC path, deferred to the
  phase 10+ bare-metal refactor. Added a precise in-line comment
  naming the platform limitation so callers don't mis-trust the
  field.

- src/tokio_transport.rs:213 map_io_error: the post-mapping logging
  previously unconditionally used `warn!` for every I/O error,
  which turned common steady-state conditions (TimedOut,
  Interrupted, ConnectionRefused during transient outages) into
  warning noise that can drown out actionable signal. Triaged by
  kind: common-path kinds drop to `debug!`; unexpected /
  misconfiguration-indicating kinds (PermissionDenied, AddrInUse,
  NetworkUnreachable, fallback Other) stay at `warn!`. Comment
  explains the rationale.

- src/transport.rs module docs: the `crate::tokio_transport::*`
  intra-doc links broke under default-feature rustdoc builds
  (the `tokio_transport` module is gated to `client`/`server`).
  Same resolution as the PR #83 intra-doc fixes in ee305e0:
  render the paths as code literals and add an inline note that
  the module requires those features. Keeps the information,
  drops the link.

No new behavior paths introduced — logging changes + docs only.
Existing tokio_transport test suite (6/6) still passes.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Follow-up to 3f93900 — the intra-doc fix for the
`crate::tokio_transport::*` links in transport.rs didn't get saved
before the commit closed. Same resolution as the PR #83 fix in
ee305e0: render feature-gated paths as code literals rather than
intra-doc links, add inline note explaining why.

Verified with `RUSTDOCFLAGS=-D rustdoc::broken-intra-doc-links
cargo doc --no-deps` — default-feature docs now clean.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Address 11 clippy::pedantic warnings introduced by this branch in
src/tokio_transport.rs:

- manual_async_fn on TransportSocket::{send_to, recv_from} and
  Timer::sleep impls: rewrite as async fn — same semantics, cleaner
  signature. Trait-side remains -> impl Future for backend flexibility.
- needless_pass_by_value on map_io_error: take &std::io::Error and
  update the handful of map_err call sites accordingly.
- trivially_copy_pass_by_ref on bind_with_options's SocketOptions:
  take by value since SocketOptions is Copy.
- field_reassign_with_default in reuse_address test: switch to struct
  update syntax.
The Err arm of the socket.recv_from select branch logged "Error
decoding message", but an Err here is a transport-level I/O failure
on the socket read — decoding happens later inside MessageView::parse.
Rename the log to "Error receiving datagram" and add a comment
distinguishing the failure mode so ops triage isn't misled.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- tokio_transport::map_io_error: doc said the original error is logged
  at warn! before mapping, but the implementation splits common
  steady-state kinds (TimedOut/Interrupted/ConnectionRefused) down to
  debug! so they don't drown out actionable warnings. Doc now lists
  both levels and explains which kinds fall into each.
- socket_manager::spawn_socket_loop: doc listed join_multicast_v4 as
  part of the per-loop I/O surface; multicast membership is actually
  joined by the caller before spawn_socket_loop runs, and the loop
  body only uses send_to/recv_from. Doc now says that explicitly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- The recv_from Err arm was logging at error!, but map_io_error in
  tokio_transport already logs the raw OS error + kind (at warn! for
  actionable kinds, debug! for steady-state noise). Drop to debug!
  here so we don't double-log the same failure at error! and inflate
  operator-facing log volume.
- Replace three awkward `if let Ok(()) = x {} else { ... }` shapes
  with the explicit `if x.is_err() { ... }` form. The original shape
  has an empty success arm + extra whitespace that's easy to misread
  in review. The encode-error arm with a populated Ok branch is also
  flipped for consistency.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Auto-applied patches landed cleanly but produced semantic conflicts
against the new transport-trait base (756f4b2):

- TokioSocket I/O methods updated from `&mut self` to `&self` to match
  the trait signature change in db44209.
- ControlMessage::reject_with_capacity now covers QueryRebootFlag and
  ForceSdSessionWrappedForTest. Their oneshot payloads aren't Result
  types so the senders are dropped (RecvError on receiver); these are
  internal/test paths, not the public APIs whose unwrap-on-RecvError
  would panic.
- Test call site for the now-async `SocketManager::bind` updated to
  `.await.unwrap()`.
- Three `mgr.subscribe(..)` test call sites now call `.unwrap()` since
  `subscribe` returns Result.
- Drop redundant `mut` bindings on now-immutable sockets.

Full lib + integration suite passes with --test-threads=1.
@JustinKovacich JustinKovacich force-pushed the feature/tokio_transport_and_socket_manager branch from 0109693 to 92cf168 Compare April 25, 2026 00:43
@JustinKovacich JustinKovacich requested a review from Copilot April 27, 2026 13:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 introduces a default Tokio-backed implementation of the crate’s executor-agnostic transport traits and migrates client networking code to use the TransportFactory/TransportSocket abstraction instead of direct socket2 usage, aligning with the transport-layer refactor introduced in #78.

Changes:

  • Add src/tokio_transport.rs providing TokioTransport/TokioSocket/TokioTimer (feature-gated behind client/server) plus tests.
  • Update client socket binding paths to construct sockets via TransportFactory + SocketOptions (and adjust call sites to async).
  • Improve transport/error docs and error display behavior (e.g., TransportError/IoErrorKind now implement Display via thiserror; server tests updated for subscribe() returning Result).

Reviewed changes

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

Show a summary per file
File Description
src/transport.rs Updates module docs and adds thiserror::Error + Display strings for transport error enums.
src/tokio_transport.rs Adds the Tokio + socket2 backend implementing the transport traits, with mapping/logging and tests.
src/client/socket_manager.rs Refactors socket creation to go through TransportFactory and updates bind APIs to async; adjusts socket loop to use ReceivedDatagram.
src/client/inner.rs Updates discovery/unicast bind flows to await the new async binds; adjusts capacity rejection behavior.
src/client/error.rs Adds Error::Transport (transparent) and a regression test for Display output.
src/server/event_publisher.rs Fixes tests to unwrap subscribe() results after signature change.
src/lib.rs Exposes the new tokio_transport module and re-exports Tokio transport types when client/server are enabled.

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

Comment thread src/client/inner.rs
Comment on lines +276 to +283
// QueryRebootFlag and ForceSdSessionWrappedForTest carry
// non-Result oneshot payloads, so there is no Err variant to
// deliver — drop the sender, which surfaces as RecvError on
// the awaiting side. These are internal/test paths, not the
// public APIs whose unwrap-on-RecvError would panic callers.
Self::QueryRebootFlag(_) => {
let _ = structure_name;
}
Comment thread src/client/error.rs
#[error("internal capacity exceeded: {0}")]
Capacity(&'static str),
/// An error surfaced by the pluggable transport backend (see
/// [`crate::transport::TransportError`]).
@JustinKovacich

Copy link
Copy Markdown
Contributor Author

Closing without merge to declutter the stack: this phase's changes are carried in full by the consolidated lineage under PR #114 (phase 21), which the next development stack builds on. Branch is retained.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants