bind-macro

Bind Rust trait objects to concrete implementations with the bind!() macro.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

This Skill unit simplifies the process of binding trait objects to concrete implementations in Rust, making dependency injection more straightforward and maintainable.

Core Features & Use Cases

  • Trait to Concrete Binding: Facilitates the binding of trait objects to concrete types, allowing for more flexible dependency injection.
  • Axum Compatibility: Ensures that dependencies can be easily used with Axum frameworks.
  • Fail Early: Detects circular dependencies, missing registrations, and scope mismatches at compile time, reducing runtime errors.
  • Test Without Container: Enables direct testing of constructors with test doubles, facilitating easier unit testing.

Quick Start

Bind the trait 'EmailSender' to the concrete type 'SmtpSender' for dependency injection.

Frequently Asked Questions about bind-macro

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

FAQPage Schema
How do I automate trait binding to concrete implementations for dependency injection in Rust?

Automating dependency injection in Rust uses the bind!() macro to map trait objects to concrete types. This simplifies binding workflows and ensures flexible dependency resolution without manual wiring.

Can I validate Rust dependency injection scopes and detect circular dependencies at compile time?

Compile-time dependency validation in Rust detects circular dependencies, missing registrations, and scope mismatches early. The bind!() macro enforces these checks during compilation to reduce runtime errors.

Does the bind!() macro work with Axum framework extractors for dynamic trait type resolution?

The bind!() macro supports Axum-compatible services requiring dynamic trait type resolution. It integrates with Axum's typed extractor model to provide dependencies directly to handlers.

How do I test Rust dependency injection constructors without spinning up a full container?

Testing dependency injection without a container allows direct testing of constructors with test doubles. This facilitates easier unit testing by injecting mock implementations directly into the bind!() macro.

What is the best way to bind an EmailSender trait to a SmtpSender concrete type in Rust?

Binding an EmailSender trait to a SmtpSender concrete type in Rust uses the bind!() macro. This maps the trait object to the specific implementation for immediate dependency injection use.

Why should I use a macro for dependency injection instead of manual trait object wiring in Rust?

Using a macro for dependency injection replaces manual trait object wiring by automating concrete type binding. It ensures maintainable code and validates missing registrations or scope mismatches at compile time.