constructor-injection

Initialize complex Rust types with constructor injection and async support.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires injectable, tokio, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill solves the challenge of initializing complex types in Rust, especially those with non-injectable fields, async initialization, or custom construction logic.

Core Features & Use Cases

  • Constructor Injection: Provides a way to initialize types with constructor injection, making it easier to manage complex initialization logic.
  • Async Initialization: Supports async initialization for types that require asynchronous operations.
  • Custom Construction Logic: Allows for custom construction logic when the default constructor does not suffice.
  • Use Case: When you have a database configuration that needs to read environment variables at startup and establish a connection to the database.

Quick Start

Initialize a new instance of AppConfig using constructor injection.

Frequently Asked Questions about constructor-injection

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

FAQPage Schema
How do I initialize complex Rust types with non-injectable fields using constructor injection?

Constructor injection in Rust initializes complex types by providing custom construction logic for non-injectable fields. This Skill manages complex initialization logic, allowing you to define exactly how types are instantiated when default methods fail.

Does Rust constructor injection support async initialization for database connections?

Yes, async initialization is fully supported for tasks like establishing database connections. By integrating tokio, the Skill handles asynchronous operations during the construction phase, ensuring types are fully ready before injection completes.

When do I need custom construction logic for dependency injection in Rust?

You need custom construction logic when types require non-injectable fields or complex startup operations. A common use case is reading environment variables at startup to establish a database connection before the application runs.

What dependencies are required to use async constructor injection in Rust?

You need the injectable and tokio crates to use this Skill. The injectable crate provides the core dependency injection framework, while tokio enables the async initialization operations required during complex type construction.

What is the best way to handle custom construction logic in a Rust dependency injection setup?

Using constructor injection is the best way to handle custom construction in Rust. It allows you to inject complex types by defining tailored initialization logic, bypassing default constructors when they are insufficient for your specific setup needs.