From 26d0ee51e232b793bc83ba565c0e9ab820d8d0db Mon Sep 17 00:00:00 2001 From: cel 🌸 Date: Thu, 17 Apr 2025 11:24:43 +0100 Subject: feat(filamento): remove sqlx --- filamento/src/roster.rs | 50 +------------------------------------------------ 1 file changed, 1 insertion(+), 49 deletions(-) (limited to 'filamento/src/roster.rs') diff --git a/filamento/src/roster.rs b/filamento/src/roster.rs index 43c32f5..ba5b3cd 100644 --- a/filamento/src/roster.rs +++ b/filamento/src/roster.rs @@ -1,14 +1,13 @@ use std::collections::HashSet; use jid::JID; -use sqlx::Sqlite; pub struct ContactUpdate { pub name: Option, pub groups: HashSet, } -#[derive(Debug, sqlx::FromRow, Clone)] +#[derive(Debug, Clone)] pub struct Contact { // jid is the id used to reference everything, but not the primary key pub user_jid: JID, @@ -18,7 +17,6 @@ pub struct Contact { // TODO: avatar, nickname /// nickname picked by contact // nickname: Option, - #[sqlx(skip)] pub groups: HashSet, } @@ -37,52 +35,6 @@ pub enum Subscription { // Remove, } -impl sqlx::Type for Subscription { - fn type_info() -> ::TypeInfo { - <&str as sqlx::Type>::type_info() - } -} - -impl sqlx::Decode<'_, Sqlite> for Subscription { - fn decode( - value: ::ValueRef<'_>, - ) -> Result { - let value = <&str as sqlx::Decode>::decode(value)?; - match value { - "none" => Ok(Self::None), - "pending-out" => Ok(Self::PendingOut), - "pending-in" => Ok(Self::PendingIn), - "pending-in-pending-out" => Ok(Self::PendingInPendingOut), - "only-out" => Ok(Self::OnlyOut), - "only-in" => Ok(Self::OnlyIn), - "out-pending-in" => Ok(Self::OutPendingIn), - "in-pending-out" => Ok(Self::InPendingOut), - "buddy" => Ok(Self::Buddy), - _ => panic!("unexpected subscription `{value}`"), - } - } -} - -impl sqlx::Encode<'_, Sqlite> for Subscription { - fn encode_by_ref( - &self, - buf: &mut ::ArgumentBuffer<'_>, - ) -> Result { - let value = match self { - Subscription::None => "none", - Subscription::PendingOut => "pending-out", - Subscription::PendingIn => "pending-in", - Subscription::PendingInPendingOut => "pending-in-pending-out", - Subscription::OnlyOut => "only-out", - Subscription::OnlyIn => "only-in", - Subscription::OutPendingIn => "out-pending-in", - Subscription::InPendingOut => "in-pending-out", - Subscription::Buddy => "buddy", - }; - <&str as sqlx::Encode>::encode(value, buf) - } -} - // none // > // >> -- cgit