microrust_inject

Crates.iomicrorust_inject
lib.rsmicrorust_inject
version0.0.0-alpha.3
created_at2025-08-03 16:43:10.604284+00
updated_at2025-08-03 19:04:03.969718+00
descriptionMicroRust Dependency Injection
homepage
repository
max_upload_size
id1779882
size22,458
Steve Schneider (schneidersteve)

documentation

README

MicroRust Dependency Injection

Asynchronous dependency injection.

Work in progress...

Features

  • struct
  • async trait
  • Mutex
  • RwLock

Example

use microrust_inject::{get_instance, inject_singleton};

struct MyStruct {}

#[inject_singleton(new)]
impl MyStruct {
    pub fn new() -> Self {
        println!("MyStruct:new() called");
        Self {}
    }

    async fn print(&self) {
        println!("Hello, MyStruct");
    }
}

#[async_std::main]
async fn main() {
    let inst = get_instance::<MyStruct>();
    //    let inst: Arc<MyStruct> = get_instance();
    inst.print().await;
}

microrust_inject_example

Commit count: 0

cargo fmt