Skip to main content

Executor

Trait Executor 

Source
pub trait Executor:
    Any
    + Send
    + Sync
    + 'static {
    // Required method
    fn as_any(&self) -> &dyn Any;
}
Expand description

An ambient handle to a unit of database work, installed in the task-local for the lifetime of a request or a worker job.

The trait is object-safe so the engine can carry it as Arc<dyn Executor> without naming a concrete ORM. The concrete handle (a SeaORM Executor enum, a sqlx::Pool, a diesel_async::Connection, …) implements this trait; an ORM-specific Repo recovers the concrete type via Executor::as_any when it needs to issue a query.

Downcasting is the documented seam: this crate stays free of every candidate ORM’s query API, and each Repo knows exactly which executor shape its Module installs. A downcast miss is a framework bug (mismatched Module + Repo) and should panic! with a clear message during boot tests, never surface as a runtime “no rows”.

Required Methods§

Source

fn as_any(&self) -> &dyn Any

Downcast handle. Used by an ORM-specific Repo to recover its concrete executor type from the ambient Arc<dyn Executor>.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§