From 962b8feae70fe1fcd58920e237662c66706c1937 Mon Sep 17 00:00:00 2001 From: MCorange Date: Mon, 15 Sep 2025 21:51:47 +0300 Subject: [PATCH] Update fn update to be in the trait, instead of a freefloating function in the struct --- persmgr_derive/src/lib.rs | 5 +---- src/db/tables/mod.rs | 1 + 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/persmgr_derive/src/lib.rs b/persmgr_derive/src/lib.rs index d46b726..985c51f 100644 --- a/persmgr_derive/src/lib.rs +++ b/persmgr_derive/src/lib.rs @@ -86,10 +86,7 @@ pub fn derive_table_meta(input: TokenStream) -> TokenStream { impl TableMeta for #ident { type PrimaryKey = #key_t; const TABLE: &'static str = #table_name; - } - - impl #ident { - pub async fn update(&mut self, pool: &crate::db::CurrPool) -> anyhow::Result { + async fn update(&mut self, pool: &crate::db::CurrPool) -> anyhow::Result { #modified_at let session = sqlx::query_as!( #ident, diff --git a/src/db/tables/mod.rs b/src/db/tables/mod.rs index b049f84..939ded9 100644 --- a/src/db/tables/mod.rs +++ b/src/db/tables/mod.rs @@ -16,6 +16,7 @@ pub mod user; pub trait TableMeta: for<'r> sqlx::FromRow<'r, PgRow> { type PrimaryKey: Type + Clone; const TABLE: &'static str; + async fn update(&mut self, pool: &crate::db::CurrPool) -> anyhow::Result; } #[derive(Debug, Clone, Default)]