| Crates.io | bisync_suffix_macro |
| lib.rs | bisync_suffix_macro |
| version | 0.1.0 |
| created_at | 2025-06-01 08:00:16.350413+00 |
| updated_at | 2025-06-01 08:00:16.350413+00 |
| description | A procedural macro to conditionally append suffixes to method names in .await expressions for dual async/blocking support. |
| homepage | |
| repository | https://github.com/okhsunrog/bisync_suffix_macro |
| max_upload_size | |
| id | 1696943 |
| size | 22,397 |
A procedural macro to conditionally append suffixes to method names in .await expressions, enabling dual support for asynchronous and blocking code paths. This macro is designed to work seamlessly with the bisync crate, allowing functions to support both async and blocking execution models based on feature flags.
The bisync_suffix_macro crate provides the suffix macro, which transforms method names in .await expressions by appending a specified suffix when the async feature is enabled. When the blocking feature is enabled (and async is not), the original method name is preserved. This macro is particularly useful in crates that need to provide both async and blocking APIs from a single codebase, such as the axp192-dd crate.
Add the following to your Cargo.toml:
[dependencies]
bisync_suffix_macro = "0.1.0"
The suffix macro is typically used within functions annotated with #[bisync] from the bisync crate. It takes two arguments: a string literal suffix (e.g., "_async") and an expression containing .await calls.
When the async feature is enabled, the macro appends the suffix to method names in .await expressions. When the blocking feature is enabled, the original method name is used, and #[bisync] removes the .await to adapt the function for blocking execution.
For detailed usage and examples, refer to the crate documentation.
This crate is dual-licensed under the MIT License or Apache License 2.0, at your option.