API Reference

Complete reference for the dependency-injector public API.

Container

The main dependency injection container. Thread-safe and can be shared across threads.

@for (method of containerMethods; track method.name) { }
Method Description Returns
{{ method.name }} {{ method.description }} {{ method.returns }}

ScopedContainer

A child container that inherits services from its parent. Created via Container::scope(). Has the same API as Container.

DiError

Error type returned when service resolution fails.

@for (error of errorVariants; track error.name) { }
Variant Description
{{ error.name }} {{ error.description }}

Traits

Injectable

Marker trait for types that can be injected. Automatically implemented for any T: Send + Sync + 'static. You don't need to implement this manually.

Provider

Internal trait for service providers. You typically don't interact with this directly.

Prelude

The prelude module exports common types for convenience:

use dependency_injector::prelude::*;
  • Container
  • ScopedContainer
  • DiError
  • Result
  • Arc