Skip to main content

ModelRuntime

Trait ModelRuntime 

Source
pub trait ModelRuntime: Send + Sync {
    // Required methods
    fn role(&self, table: &str) -> Option<ModelRole>;
    fn write<'a>(
        &'a self,
        tx: &'a Transaction,
        ast: QueryAst,
    ) -> TransactionFuture<'a, ModelWriteResult>;

    // Provided methods
    fn captures_table(&self, table: &str) -> bool { ... }
    fn transaction_lock(&self) -> Option<Arc<Mutex<()>>> { ... }
    fn prepare_read(&self, ast: QueryAst) -> QueryAst { ... }
    fn authorize_read(&self, _ast: &QueryAst) -> Result<(), OrmError> { ... }
}
Expand description

Transactional extension point for registered model writes. Implementations use raw transaction methods internally to avoid recursively capturing writes.

Required Methods§

Source

fn role(&self, table: &str) -> Option<ModelRole>

Source

fn write<'a>( &'a self, tx: &'a Transaction, ast: QueryAst, ) -> TransactionFuture<'a, ModelWriteResult>

Provided Methods§

Source

fn captures_table(&self, table: &str) -> bool

Also intercept ordinary tables whose SQL referential actions affect tracked models.

Source

fn transaction_lock(&self) -> Option<Arc<Mutex<()>>>

Source

fn prepare_read(&self, ast: QueryAst) -> QueryAst

Source

fn authorize_read(&self, _ast: &QueryAst) -> Result<(), OrmError>

Recheck access for every SELECT, including nested subqueries, counts, relation loading, and SELECTs embedded in ordinary mutation predicates.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§