generic-injection

Automate generic dependency injection for Rust structs with Axum compatibility.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

This Skill addresses the challenge of making generic structs injectable in Rust, enabling seamless propagation of type parameters through Provider and Injectable impls.

Core Features & Use Cases

  • Generic Struct Injection: Allows generic structs to be injected with dependencies, facilitating reuse and flexibility.
  • Type Propagation: Ensures type parameters are passed through to generated Provider and Injectable impls.
  • Axum Compatibility: Works seamlessly with Axum, allowing dependencies to be injected into handler signatures.
  • Fail Early: Detects circular dependencies, missing registrations, and scope mismatches during container build phase.
  • Testing Flexibility: Enables direct testing of constructors without the container.

Quick Start

Use the generic-injection skill to make a generic struct like 'Wrapper<T>' injectable, and resolve it with 'container.resolve::<Wrapper<Database>>()'.

Frequently Asked Questions about generic-injection

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

FAQPage Schema
How do I make generic structs injectable in a Rust DI container?

Generic struct injection in Rust propagates type parameters through generated Provider and Injectable impls, allowing dependencies to be resolved directly within the DI container.

Does Rust dependency injection work with Axum handler signatures?

Yes, Rust dependency injection works seamlessly with Axum, allowing resolved dependencies to be injected directly into handler signatures. This compatibility ensures your web routes receive the required generic struct instances automatically.

How do I resolve a generic struct instance from a DI container in Rust?

You resolve a generic struct instance by calling `container.resolve::<Wrapper<Database>>()` in Rust. This skill automates the underlying type parameter propagation so the container can construct and return the correct generic instance.

When does a Rust DI container detect circular dependencies and missing registrations?

A Rust DI container detects circular dependencies, missing registrations, and scope mismatches during the early container build phase. This fail-fast approach ensures invalid dependency graphs are caught before runtime execution begins.

Can I test Rust struct constructors directly without a DI container?

Yes, you can test Rust struct constructors directly without a DI container. This skill provides testing flexibility by enabling direct invocation of constructors, bypassing the need to bootstrap the entire container for isolated unit tests.

What is the best way to automate type parameter propagation for Rust dependency injection?

The best way to automate type parameter propagation for Rust dependency injection is using a code generation skill that creates the necessary Provider and Injectable impls. This eliminates manual boilerplate when wiring generic structs.