About
SyncA is a framework for creating crates with both synchronous and asynchronous versions.
Docs
Motivation
When we write a library, we cannot control the environment in which our code will be used.
Often this leads to the fact that there is only a synchronous version, or two different crates. If the problems of the first solution are obvious, then the second leads to a violation of the DRY principle.
SyncA solves this problem by hiding the asynchronous implementation behind a feature.
Concept
One macro for everything.
The macro synca::synca generates 2 versions of code: async with attribute #[cfg(feature)] and sync with attribute #[cfg(not(feature))].
Full example
/// # synca
///
/// The macro will create 2 versions of the my_mod
/// With the asynchrony feature enabled - asynchronous version,
/// without it - synchronous.
/// # Functions
///
/// The macro turns asynchronous functions into synchronous
/// implementations - removing all the .await calls
/// # Types
///
/// synca supports type substitution
/// The synchronous version will use type postgres::Client
/// # Tests
///
/// synca support attributes substitution too.
/// This allows you to test not only the asynchronous version, but also the synchronous one
/// # Traits
///
/// synca also knows how to work with traits
/// # Docs
///
/// synca also contains a documentation processor that allows to generate
/// different documentation for the synchronous and asynchronous versions
///
/// [synca::sync]
/// It's sync doc
/// [/synca::sync]
/// [synca::async]
/// It's async doc
/// [/synca::async]
///
/// # Match
///
/// You can also use "synca::match" to replace part of a string.
///
/// Arguments
/// - [synca::match]tokio_postgres|postgres[/synca::match]::Client - postgres client
pub async
/// # Virtual attributes
///
/// - synca::ignore - ignore in code fold
/// - synca::sync_only - the code will only be available in the synchronous version
/// - synca::async_only - the code will only be available in the asynchronous version