bisync_suffix_macro

Crates.iobisync_suffix_macro
lib.rsbisync_suffix_macro
version0.1.0
created_at2025-06-01 08:00:16.350413+00
updated_at2025-06-01 08:00:16.350413+00
descriptionA procedural macro to conditionally append suffixes to method names in .await expressions for dual async/blocking support.
homepage
repositoryhttps://github.com/okhsunrog/bisync_suffix_macro
max_upload_size
id1696943
size22,397
Danila Gornushko (okhsunrog)

documentation

https://docs.rs/bisync_suffix_macro/

README

bisync_suffix_macro

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.

Description

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.

Installation

Add the following to your Cargo.toml:

[dependencies]
bisync_suffix_macro = "0.1.0"

Usage

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.

License

This crate is dual-licensed under the MIT License or Apache License 2.0, at your option.

Commit count: 5

cargo fmt