flexi_func_declarative 0.2.2

This crate exposes the fb! macro to create a function with a flexible signature.
Documentation

# 📦 Flexi Func Declarative 🚀


Welcome to **Flexi Func Declarative** - a Rust crate designed to supercharge your Rust programming experience with two powerful macros: `ff` (Flexi Func) and `fb` (Flexi Block) *or* (Function Builder) 🛠️.

These macros are crafted to simplify and enhance the way you write synchronous and asynchronous code, making your Rust journey smoother and more efficient.

## 🎁 Features


- **`fb!` (Flexi Block) *or* (Function Builder)**: Inside the sync function write down your (`sync` or `async`) versions using fb!
- **`fb!`** Reducing the boilerplate for conditional function generation 🔄.

## 🚀 Getting Started


This crate is meant to be used with and supplement the flexi_func crate.
To start using **flexi_func** in your project, add it to your `Cargo.toml`:

```toml
[dependencies]
flexi_func = "0.2.2"
```

Then, import the macros in your Rust file:

```rust
use flexi_func::{ff, fb};
```

## 💻 Usage


### 🛠 `ff` - Flexi Func


The `ff` macro simplifies the creation of synchronous and asynchronous function variants, including customizable error handling.

#### Basic Example


```rust
#[ff]

fn compute(data: Vec<u8>) -> Result<usize, MyError> {
    // Your synchronous code here
}
```

This generates an asynchronous version `compute_async` alongside the original `compute` function.  
If you need to specify an async version of your code inside your sync function use the fb! declarative macro.

### 🐞 Custom Error Type


```rust
#[ff(error_type = "MyCustomError")]

fn process(data: Vec<u8>) -> Result<usize, MyCustomError> {
    // Your code here
}
```

### 🔄 `fb!` - Flexi Block or Function Builder


Create asynchronous twin functions & code blocks on the fly with `fb!`, tailored to reduce redundancy and improve code clarity.

#### ✅ Synchronous Function


```rust
fb!(sync, greet, (name: String), -> String, {
    format!("Hello, {}", name)
});
```

#### ⚡ Asynchronous Function


```rust
fb!(async, fetch_data, (url: String), -> Result<String, reqwest::Error>, {
    // Async fetch operation
});
```

## 💡 Advanced Tips


- Use conditional compilation with `fb!` to adaptively generate sync or async functions based on your application's needs 🎛️.
- Combine `ff` with Rust's powerful error handling to streamline async error management 🚦.

## 🐳 Contributing


Contributions are welcome! If you'd like to help improve **flexi_func**, please feel free to create issues or submit pull requests 🤝.

## 📃 License


This project is licensed under [MIT](LICENSE.md).