{"id":23387084,"url":"https://github.com/thehamdiz/flexi_func","last_synced_at":"2025-04-08T12:33:19.598Z","repository":{"id":221573164,"uuid":"754737382","full_name":"theHamdiz/flexi_func","owner":"theHamdiz","description":"FlexiFunc abbreviated as ff is  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.","archived":false,"fork":false,"pushed_at":"2024-02-11T16:38:46.000Z","size":16,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T10:49:26.188Z","etag":null,"topics":["async","macro","macros","macros-rust","metaprogramming","rust","rust-lang","sync"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/theHamdiz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-08T17:10:35.000Z","updated_at":"2024-06-17T07:34:53.000Z","dependencies_parsed_at":"2025-02-14T08:33:09.143Z","dependency_job_id":"000bd22b-023a-4fd5-a07d-8627bf58344d","html_url":"https://github.com/theHamdiz/flexi_func","commit_stats":null,"previous_names":["thehamdiz/flexi_func"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theHamdiz%2Fflexi_func","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theHamdiz%2Fflexi_func/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theHamdiz%2Fflexi_func/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theHamdiz%2Fflexi_func/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theHamdiz","download_url":"https://codeload.github.com/theHamdiz/flexi_func/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247843040,"owners_count":21005391,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async","macro","macros","macros-rust","metaprogramming","rust","rust-lang","sync"],"created_at":"2024-12-22T01:14:33.839Z","updated_at":"2025-04-08T12:33:19.575Z","avatar_url":"https://github.com/theHamdiz.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# 📦 Flexi Func 🚀\n\nWelcome to **Flexi Func** - a Rust crate designed to supercharge your Rust programming experience with two powerful macros: `ff` (Flexi Func) and `fb` (Flexi Block) *or* (Function Builder) 🛠️.  \n\nThese macros are crafted to simplify and enhance the way you write synchronous and asynchronous code, making your Rust journey smoother and more efficient.\n\n## 🎁 Features\n\n- **`ff` (Flexi Func)**: Mark your async function with this proc macro first, with optional custom error handling 🌟.\n- **`fb!` (Flexi Block) *or* (Function Builder)**: Inside the sync function write down your (`sync` or `async`) versions using fb!  \n- **`fb!`** Reducing the boilerplate for conditional function generation 🔄.\n\n## 🚀 Getting Started\n\nTo start using **flexi_func** in your project, add it to your `Cargo.toml`:\n\n```toml\n[dependencies]\nflexi_func = \"0.2.7\"\n```\n\nThen, import the macros in your Rust file:\n\n```rust\nuse flexi_func::{ff, fb};\n```\n\n## 💻 Usage\n\n### 🛠 `ff` - Flexi Func\n\nThe `ff` macro simplifies the creation of synchronous and asynchronous function variants, including customizable error handling.\n\n#### Basic Example\n\n```rust\n#[ff]\nfn compute(data: Vec\u003cu8\u003e) -\u003e Result\u003cusize, MyError\u003e {\n    // Your synchronous code here\n}\n```\n\nThis generates an asynchronous version `compute_async` alongside the original `compute` function.  \nIf you need to specify an async version of your code inside your sync function use the fb! declarative macro.\n\n### 🐞 Custom Error Type\n\n```rust\n#[ff(error_type = \"MyCustomError\")]\nfn process(data: Vec\u003cu8\u003e) -\u003e Result\u003cusize, MyCustomError\u003e {\n    // Your code here\n}\n```\n\n\n### 🔄 `fb!` - Flexi Block or Function Builder\n\nEnhance your Rust arsenal with `fb!`, a versatile macro designed to dynamically generate both synchronous and asynchronous functions or code blocks. This macro is engineered to minimize redundancy and elevate code clarity, offering a seamless way to craft adaptable code constructs.\n\n#### ✅ Synchronous Function\n\nCreate a synchronous function with ease:\n\n```rust\nfb!(sync, greet, (name: String), -\u003e String, {\n    format!(\"Hello, {}\", name)\n});\n```\n\n#### ⚡ Asynchronous Function\n\nGenerate an asynchronous function for operations that require awaiting:\n\n```rust\nfb!(async, fetch_data, (url: String), -\u003e Result\u003cString, reqwest::Error\u003e, {\n    // Async fetch operation\n});\n```\n\n#### 🔄 Returning a Closure\n\nFor scenarios where you need to capture the surrounding environment or defer execution:\n\n- **Async Closure**\n\n```rust\nlet async_closure = fb!(async, closure, {\n    // Async code here\n});\n// Usage\nasync_closure().await;\n```\n\n- **Sync Closure**\n\n```rust\nlet sync_closure = fb!(sync, closure, {\n    // Sync code here\n});\n// Usage\nsync_closure();\n```\n\n#### 🚀 Immediate Execution\n\nExecute code blocks immediately, without the need to define a separate function:\n\n- **Async Block**\n\n```rust\nlet result = fb!(async, execute, {\n    // Immediate async execution\n});\n// Await the block if necessary\nresult.await;\n```\n\n- **Sync Block**\n\n```rust\nfb!(sync, execute, {\n    // Immediate sync execution\n});\n```\n\n## 💡 Advanced Tips\n\n- Leverage `fb!` for conditional compilation to dynamically generate sync or async functions, tailoring your code to the application's needs 🎛️.\n- Enhance error management in async operations by combining `fb!` with Rust's robust error handling features 🚦.\n\n## 🐳 Contributing\n\nWe welcome contributions to make `fb!` even better. If you're interested in enhancing its functionality or have suggestions, feel free to open issues or submit pull requests 🤝. Your input is invaluable in evolving this tool.\n\n## 📃 License\n\nThis project is licensed under the [MIT License](LICENSE.md), fostering open collaboration and innovation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthehamdiz%2Fflexi_func","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthehamdiz%2Fflexi_func","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthehamdiz%2Fflexi_func/lists"}