Skip to main content

Adapter

Trait Adapter 

Source
pub trait Adapter: Queries + 'static {
    type Tx: Transaction;

    // Required methods
    fn begin(&self) -> impl Future<Output = Result<Self::Tx, DbError>> + Send;
    fn introspect(
        &self,
    ) -> impl Future<Output = Result<LiveSchema, DbError>> + Send;
    fn apply(
        &self,
        plan: &MigrationPlan,
    ) -> impl Future<Output = Result<(), DbError>> + Send;

    // Provided methods
    fn render_sql(&self, plan: &MigrationPlan) -> Result<String, DbError> { ... }
    fn session_with_user(
        &self,
        q: SessionWithUser<'_>,
    ) -> impl Future<Output = Result<Option<(Row, Row)>, DbError>> + Send { ... }
}

Required Associated Types§

Required Methods§

Source

fn begin(&self) -> impl Future<Output = Result<Self::Tx, DbError>> + Send

Source

fn introspect(&self) -> impl Future<Output = Result<LiveSchema, DbError>> + Send

Reads the live schema for the migrator. Adapters without DDL return Unsupported.

Source

fn apply( &self, plan: &MigrationPlan, ) -> impl Future<Output = Result<(), DbError>> + Send

Applies a migration plan computed by the migrator.

Provided Methods§

Source

fn render_sql(&self, plan: &MigrationPlan) -> Result<String, DbError>

Renders a plan as SQL for fastauth generate. Non-SQL adapters return Unsupported.

Source

fn session_with_user( &self, q: SessionWithUser<'_>, ) -> impl Future<Output = Result<Option<(Row, Row)>, DbError>> + Send

Session plus user in one call. The default does two lookups; SQL adapters override.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl Adapter for MemoryAdapter

Source§

impl<DB> Adapter for Sqlx<DB>
where DB: Dialect,

Source§

type Tx = SqlxTx<DB>