inject-fn-macro

Create dependency-injected factory functions in async Rust with the #[injectable(factory)] macro.

Updated May 10, 2026
One-click install
npx skills add https://github.com/jymchng/injectable --skill inject-fn-macro
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: inject-fn-macro
Source: https://github.com/jymchng/injectable/tree/main/skills/inject-fn-macro
Command: npx skills add https://github.com/jymchng/injectable --skill inject-fn-macro

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

The problem solved is the difficulty in writing dependency-injected factory functions for async Rust applications.

Core Features & Use Cases

  • Transform Functions into Factories: Easily create factory functions for dependencies with the #[injectable(factory)] macro.
  • Async Compatibility: Ensure factory functions work well with async applications.
  • Compile-time Safety: Prevent runtime errors like circular dependencies and missing registrations during build time.
  • Unit Testing: Allows for easy unit testing by using plain Rust constructors directly.

Quick Start

Create an async factory for database pooling using the provided macro.

Frequently Asked Questions about inject-fn-macro

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create async dependency injection factories in Rust without runtime errors?

You can create async dependency injection factories in Rust by applying the #[injectable(factory)] macro to automate function generation. This approach enforces compile-time safety, preventing circular dependencies and missing registrations during the build process.

What is the best way to simplify dependency injection for async Rust applications?

The best way to simplify dependency injection for async Rust applications is using an injection framework macro. It transforms plain functions into async-compatible factory functions, reducing boilerplate while maintaining compile-time safety.

Can I use async factory functions for dependency injection while still unit testing plain Rust constructors?

Yes, you can use async factory functions for dependency injection while retaining direct unit testing capabilities. The macro allows you to bypass the injected factories and test dependencies using plain Rust constructors directly.

How does compile-time safety work with async dependency injection frameworks in Rust?

Compile-time safety in async dependency injection frameworks works by validating dependency graphs during the Rust build process. The macro detects issues like circular dependencies and missing registrations before runtime, ensuring application stability.

Do I need a specific dependency injection framework to use async factory macros in Rust?

No external runtime dependency injection framework is required to use async factory macros in Rust. The macro operates directly on your codebase with zero external dependencies, automating factory creation natively through Rust's compile-time checks.