easy-sql 0.101.1

Macro-first SQL toolkit with compile-time checked queries, optional migrations on top of sqlx.
Documentation
use easy_macros::always_context;
use sqlx::Executor;

use crate::Driver;

use super::DriverArguments;

#[always_context]
#[async_trait::async_trait]
/// Conversion helper used by [`Output`].
///
/// Driver integrations provide implementations for their row types.
pub trait ToConvert<D: Driver> {
    async fn get<'a>(
        exec: impl Executor<'_, Database = D::InternalDriver>,
        query: sqlx::query::Query<'a, D::InternalDriver, DriverArguments<'a, D>>,
    ) -> anyhow::Result<Self>
    where
        Self: Sized;
}

#[always_context]
/// Output mapping for query results.
///
/// Prefer implementing this trait via the [`Output`](macro@crate::Output) derive macro; manual
/// implementations may need updates across releases.
pub trait Output<Table, D: Driver>: Sized {
    type DataToConvert: ToConvert<D>;
    type UsedForChecks;

    fn select(current_query: &mut String);
    fn convert(data: Self::DataToConvert) -> anyhow::Result<Self>;
}