Async Pub Sub Macros
This crate provides procedural macros for the async_pub_sub crate, simplifying the implementation of publishers, subscribers, and RPC interfaces.
Features
DerivePublisher
: A derive macro to automatically implement thePublisher
trait for structs. It supports single and multi-publisher scenarios, including specifying message types via attributes.DeriveSubscriber
: A derive macro to automatically implement theSubscriber
trait for structs. It supports single and multi-subscriber scenarios.rpc_interface
: An attribute macro that generates the necessary code for defining RPC interfaces, including message enums (with optional derive attributes), client traits, and server traits.route
androutes
: Macros for easily connecting publishers and subscribers.
Usage
- Add
async_pub_sub
andasync_pub_sub_macros
to yourCargo.toml
:
[]
= "0.1.0" # Replace with the latest version
= "0.1.0" # Replace with the latest version
Alternatively, you can use the macros feature on the async_pub_sub crate
[] = { = "0.1.0", = ["macros"] } # Replace with the latest version
- Use the derive and attribute macros in your code:
use ;
use ;
// Publisher example
// Subscriber example
// RPC interface example
// RPC interface with custom derives for the message enum
See the tests/expand directory for more detailed usage examples and to see the code generated by the macros.
License
This project is licensed under the MIT License - see the LICENSE file for details.