Skip to content

Conversation

@ivmarkov
Copy link
Collaborator

@ivmarkov ivmarkov commented Nov 22, 2025

The purpose of edge-nal-embassy is to provide implementations for the edge-nal traits on top of embassy-net.

Therefore, the expectation is that the public struct types of edge-nal-embassy for TCP/UDP sockets would rarely be used and instead - the user would write their code against the edge-nal traits to achieve platform independence.

Nevertheless - and especially if some of these types need to be put in a static context with embassy's make_static! / mk_static! macros - the fact that the edge-nal-embassy types are so heavily generified with const generics is inconvenient, as the user has to type the full types, with their N, TX_SZ, RX_SZ, M generics.

This PR is erasing all of the const generics (coming from the TCP/UDP buffers' pool) by using not the Pool type but rather, a new sealed DynPool trait which - furthermore - is injected in the Tcp/Udp types and their sockets as a &dyn trait (hence its own type is also erased).

As a result, Tcp/Udp/TcpSocket/UdpSocket have now all their const generics removed and have just a single lifetime generic.

Additionally, Tcp , Udp and Dns are now Copy just like the underlying embassy-net Stack type for extra user convenience.

@ivmarkov ivmarkov changed the title Erase const generics from the edge-nal-embassy types Erase the const generics from the edge-nal-embassy types Nov 22, 2025
Copy link

Copilot AI left a comment

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 refactors the edge-nal-embassy crate to remove const generics from its public types (Tcp, Udp, TcpSocket, UdpSocket, etc.) by introducing a new trait-based abstraction DynPool that uses dynamic dispatch. This makes the types easier to use, especially in static contexts with Embassy's make_static! macros. The PR also makes these types Copy and Clone for user convenience, matching the underlying embassy-net::Stack type. Additionally, it adds comprehensive documentation to the edge-nal-std crate.

Key changes:

  • Introduced sealed DynPool trait with dynamic dispatch to erase const-generic pool parameters
  • Refactored socket buffer management to use token-based allocation with type-erased pools
  • Added Copy/Clone derives to Tcp, Udp, Dns, and Stack types for easier usage
  • Enhanced documentation across both edge-nal-embassy and edge-nal-std crates

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
edge-nal-embassy/src/lib.rs Introduces DynPool trait with sealed implementation, makes Pool public, adds helper function docs
edge-nal-embassy/src/tcp.rs Removes const generics from Tcp/TcpSocket, uses DynPool for buffer management, adds comprehensive documentation
edge-nal-embassy/src/udp.rs Removes const generics from Udp/UdpSocket, uses DynPool for buffer management, changes default buffer sizes, adds documentation
edge-nal-embassy/src/dns.rs Adds Copy/Clone derives and documentation to Dns type
edge-nal-std/src/lib.rs Adds Copy derive to Stack and Interface, enhances documentation for public API
edge-nal-embassy/CHANGELOG.md Documents the const-generics erasure and Copy trait additions
edge-nal-std/CHANGELOG.md Documents the API documentation and Copy trait additions

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

@ivmarkov ivmarkov merged commit 85366c1 into master Nov 23, 2025
2 checks passed
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.

2 participants