✨ Replaced async_trait with async in traits from 2024 edition
This commit is contained in:
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user