scoping

Manage Singleton, Transient, and RequestScoped lifetimes for Axum dependency injection.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill helps manage the scope of injectable types, ensuring types are created and shared appropriately for different scenarios.

Core Features & Use Cases

  • Scope Management: Provides control over the lifetime and sharing of injected types.
  • Singleton: Ensures a single instance of a type across the entire application.
  • Transient: Creates a new instance of a type every time it is injected.
  • RequestScoped: Delivers a new instance for each HTTP request.
  • Use Case: When building a web application with Axum, use RequestScoped for database transactions to ensure a fresh transaction for each request.

Quick Start

Use the scoping skill to set the scope of a database transaction to RequestScoped.

Frequently Asked Questions about scoping

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

FAQPage Schema
How do I manage dependency injection scopes in Rust Axum web applications?

RequestScoped dependency injection provides a new type instance for each HTTP request in Axum. It manages type scope to ensure resources like database transactions are isolated per request, preventing cross-request data leaks.

What is the difference between Singleton, Transient, and RequestScoped dependency injection?

Singleton shares one type instance across the entire application, Transient creates a new instance every time it is injected, and RequestScoped delivers a new instance for each HTTP request.

Do I need the injectable library to use scoped dependency injection in Rust?

Yes, the injectable library is required to use scoped dependency injection. This Skill builds upon it to manage the scope of injectable types within your Rust application for better resource management.

How do I set a database transaction to RequestScoped in an Axum application?

Set a database transaction to RequestScoped by applying this scope definition to the injectable type. This ensures the dependency injection container delivers a fresh transaction instance for every individual HTTP request.

When should I use scoped dependency injection for type management?

Use scoped dependency injection when building web applications with Axum and you need precise control over type lifetimes. It solves resource management problems by ensuring types are shared appropriately across different scenarios like single requests or the entire application.