Replaced async_trait with async in traits from 2024 edition

This commit is contained in:
2025-03-07 22:40:10 +01:00
parent 2f1eb4df3a
commit 5a77407297
16 changed files with 90 additions and 127 deletions

View File

@ -1,5 +1,5 @@
use crate::common::PrimaryKey;
use crate::{common, Attributes};
use crate::{Attributes, common};
use quote::quote;
pub(crate) fn derive_diesel_crud_read_impl(
@ -20,20 +20,14 @@ pub(crate) fn derive_diesel_crud_read_impl(
#[automatically_derived]
impl lib::diesel_crud_trait::DieselCrudRead for #struct_ident {
type PK = #pk_type;
fn read<'a, 'async_trait>(pk: Self::PK, conn: &'a mut diesel_async::AsyncPgConnection) -> #return_type
where
Self: Sized + Sync + 'a,
'a: 'async_trait
{
Box::pin(async move {
use diesel::associations::HasTable;
diesel_async::RunQueryDsl::get_result(
diesel::QueryDsl::find(#table::table::table(), pk),
conn
)
.await
.map_err(Into::into)
})
async fn read(pk: Self::PK, conn: &mut diesel_async::AsyncPgConnection) -> #return_type {
use diesel::associations::HasTable;
diesel_async::RunQueryDsl::get_result(
diesel::QueryDsl::find(#table::table::table(), pk),
conn
)
.await
.map_err(Into::into)
}
}
}