Skip to main content

DbContextResolver

Trait DbContextResolver 

Source
pub trait DbContextResolver {
    // Required methods
    fn get_owned_context(
        &self,
        key: impl IDbContextKey + Into<ServiceKey>,
    ) -> Result<DbContext, RdiError>;
    fn get_context(
        &self,
        key: impl IDbContextKey + Into<ServiceKey>,
    ) -> Result<Arc<DbContext>, RdiError>;
}
Expand description

Typed-context resolution helpers.

Keys are registered through rust-dix’s typed ServiceKey path: enum key types implementing Into<ServiceKey> (usually via #[derive(DbContextKey)]) register a typed key; &str/String keys keep their String key. The two forms are not interchangeable, matching rust-dix 0.10+ semantics. get_context requires a scope (strict scope validation); use DbContextResolver::get_owned_context for root-safe owned resolution.

Required Methods§

Source

fn get_owned_context( &self, key: impl IDbContextKey + Into<ServiceKey>, ) -> Result<DbContext, RdiError>

Resolve an owned DbContext for key (allowed from the root provider).

Source

fn get_context( &self, key: impl IDbContextKey + Into<ServiceKey>, ) -> Result<Arc<DbContext>, RdiError>

Resolve a shared Arc<DbContext> for key (requires a scope).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl DbContextResolver for Scope

Implementors§