Skip to main content

Adapter

Trait Adapter 

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

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

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

Required Associated Types§

Required Methods§

Source

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

Source

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

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

Source

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

Applies a migration plan computed by the migrator.

Provided Methods§

Source

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

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

Source

fn session_with_user( &self, q: SessionWithUser<'_>, ) -> impl Future<Output = DbResult<Option<(Row, Row)>>> + 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§