#events #subscriber #nanoservices #subscribe #tokio

macro nan-serve-event-subscriber

Tokio event subscriber for nanoservices

1 unstable release

0.1.0 Jan 5, 2025

#477 in Procedural macros

Download history 144/week @ 2025-01-01 21/week @ 2025-01-08

165 downloads per month
Used in nanoservices-utils

MIT license

6KB
88 lines

Nanoservices event subscriber

A basic proc macro crate for subscribing to events. We can subscribe to events with the following code:

#[derive(Serialize, Deserialize, Debug)]
struct Two;

#[subscribe_to_event]
async fn test2(two: Two) {
    println!("calling from test2 function with: {:?}", two);
}

This generates the code for a standard function under the name as it is defined as, and a slightly mangled function which is registered with the event subscriber. If an event is then published with the Two then all functions subscribed to the Two event will be called with the instance of the Two struct.

Dependencies

~215–650KB
~15K SLoC