Skip to main content

Injectable

Trait Injectable 

Source
pub trait Injectable:
    Send
    + Sync
    + 'static {
    // Provided methods
    fn type_id_of() -> TypeId
       where Self: Sized { ... }
    fn type_name_of() -> &'static str
       where Self: Sized { ... }
}
Expand description

Marker trait for types that can be injected via the DI container.

This is automatically implemented for all types that are Send + Sync + 'static. You never need to implement this manually.

§Examples

// Any type that is Send + Sync + 'static works automatically
#[derive(Clone)]
struct MyService {
    name: String,
}

// No impl needed - it just works!

Provided Methods§

Source

fn type_id_of() -> TypeId
where Self: Sized,

Returns the TypeId of this type (for internal use)

Source

fn type_name_of() -> &'static str
where Self: Sized,

Returns the type name for debugging

Implementors§

Source§

impl<T: Send + Sync + 'static> Injectable for T