diff options
Diffstat (limited to 'filamento/src/roster.rs')
-rw-r--r-- | filamento/src/roster.rs | 50 |
1 files changed, 1 insertions, 49 deletions
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<String>, pub groups: HashSet<String>, } -#[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<String>, - #[sqlx(skip)] pub groups: HashSet<String>, } @@ -37,52 +35,6 @@ pub enum Subscription { // Remove, } -impl sqlx::Type<Sqlite> for Subscription { - fn type_info() -> <Sqlite as sqlx::Database>::TypeInfo { - <&str as sqlx::Type<Sqlite>>::type_info() - } -} - -impl sqlx::Decode<'_, Sqlite> for Subscription { - fn decode( - value: <Sqlite as sqlx::Database>::ValueRef<'_>, - ) -> Result<Self, sqlx::error::BoxDynError> { - let value = <&str as sqlx::Decode<Sqlite>>::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 <Sqlite as sqlx::Database>::ArgumentBuffer<'_>, - ) -> Result<sqlx::encode::IsNull, sqlx::error::BoxDynError> { - 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<Sqlite>>::encode(value, buf) - } -} - // none // > // >> |