helper-generator
A Rust procedural macro library that automates the creation of MPSC (Multi-Producer, Single-Consumer) message channel helpers and related utilities. It significantly reduces boilerplate code when building concurrent, message-passing systems using Tokio's async runtime.
Installation
Add to your Cargo.toml:
[]
= "0.7.0"
Features
This library provides three procedural macros:
#[derive(Helper)] - MPSC Communication Helper
Automatically generates a helper struct with methods to send enum variants through an MPSC channel.
use Helper;
// Generated:
// - MyHelper struct with async send methods
// - MyEventReceiver type alias
// - MyHelper::new(channel_size) constructor
Generated methods:
Attributes:
#[helper(block)]- Generate blocking send methods in addition to async#[helper(no_async)]- Generate only blocking methods (no async)- Per-variant attributes to override behavior
#[oneshot_helper] - Request-Response Communication
Extends Helper to support request-response patterns using oneshot channels.
use oneshot_helper;
Methods return the response type wrapped in Option:
#[bit_helper] - Bit Flag Utilities
Generates bit flag enums with checker methods.
use bit_helper;
Generated methods:
Naming Convention
Enum variant names are automatically converted to snake_case for method names:
| Variant Name | Method Name |
|---|---|
UserLogin |
user_login() |
GetHTTPResponse |
get_http_response() |
XMLParser |
xml_parser() |
Requirements
- The enum name must contain "Event" for
Helperandoneshot_helpermacros (e.g.,MyEvent,AppEvent) - Tokio runtime for async methods
License
AGPL-3.0-or-later
Author
KunoiSayami