16 releases (8 breaking)

Uses new Rust 2024

new 0.30.1 May 2, 2025
0.30.0-rc.2 Apr 24, 2025
0.29.1 Mar 6, 2025
0.28.0 Dec 10, 2024
0.20.1 Mar 6, 2024

#2050 in Procedural macros

Download history 175/week @ 2025-01-12 274/week @ 2025-01-19 57/week @ 2025-01-26 222/week @ 2025-02-02 285/week @ 2025-02-09 200/week @ 2025-02-16 224/week @ 2025-02-23 242/week @ 2025-03-02 169/week @ 2025-03-09 168/week @ 2025-03-16 151/week @ 2025-03-23 172/week @ 2025-03-30 203/week @ 2025-04-06 75/week @ 2025-04-13 183/week @ 2025-04-20 204/week @ 2025-04-27

673 downloads per month
Used in near-async

MIT/Apache

22KB
371 lines

This crate provides a set of procedural macros for deriving traits for multi-sender types, which are structs that contain multiple Sender and AsyncSender fields. The structs can either have named fields or be a tuple struct.

The derive macros provided by this crate allows multi-senders to be created from anything that behaves like all of the individual senders, and allows the multi-sender to be used like any of the individual senders. This can be very useful when one component needs to send multiple kinds of messages to another component; for example the networking layer needs to send multiple types of messages to the ClientActor, each expecting a different response; it would be very cumbersome to have to construct the PeerManagerActor by passing in 10 different sender objects, so instead we create a multi-sender interface of all the senders and pass that in instead.

To better understand these macros,

  • Look at the tests in this crate for examples of what the macros generate.
  • Search for usages of the derive macros in the codebase.

Dependencies

~200–630KB
~15K SLoC