InjectableExtension

Trait InjectableExtension 

Source
pub trait InjectableExtension:
    Sized
    + Send
    + Sync
    + 'static {
    // Required method
    fn create_factory() -> ServiceFactory;
}
Expand description

Extension trait for types that can be automatically injected.

This trait is automatically implemented when you use the #[derive(Injectable)] macro. It generates a factory function that resolves all dependencies from the service provider.

§Example

use service_rs::{Injectable, ServiceCollection};
use std::sync::Arc;

#[derive(Injectable)]
struct MyService {
    dependency: Arc<i32>,
}

Required Methods§

Source

fn create_factory() -> ServiceFactory

Creates a factory function for this type.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§