volga-di

Crates.iovolga-di
lib.rsvolga-di
version0.6.4
created_at2025-08-01 14:01:16.958974+00
updated_at2025-09-05 16:22:58.266827+00
descriptionDependency Injection tools for Volga Web Framework
homepagehttps://romanemreis.github.io/volga-docs
repositoryhttps://github.com/RomanEmreis/volga
max_upload_size
id1776836
size28,047
Roman (RomanEmreis)

documentation

https://docs.rs/volga

README

Volga DI

A standalone, flexible, and easy-to-configure DI container.

latest latest License: MIT Build Release

💡 Note: This project is currently in preview. Breaking changes can be introduced without prior notice.

Getting Started

Dependencies

Standalone

[dependencies]
volga-di = "0.6.4"

Part of Volga Web Framework

[dependencies]
volga = { version = "0.6.3", features = ["di"] }

Derive-macro support

[dependencies]
volga = { version = "0.6.4", features = ["di-full"] }

Example

use std::collections::HashMap;
use std::sync::{Arc, Mutex};

#[derive(Default)]
struct InMemoryCache {
    inner: Arc<Mutex<HashMap<String, String>>>
}

fn main() {
    let mut container = ContainerBuilder::new();
    container.register_singleton(InMemoryCache::default());

    let container = container.build();

    let Ok(cache) = container.resolve::<InMemoryCache>() else { 
        eprintln!("Unable to resolve InMemoryCache")
    };

    // Do work...
}
Commit count: 169

cargo fmt