From 61b755c890dcaa66daa35942ca87cc00269b0fe9 Mon Sep 17 00:00:00 2001 From: cel 🌸 Date: Thu, 17 Apr 2025 17:30:22 +0100 Subject: feat(filamento): full wasm support by switching to rusqlite --- jid/src/lib.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'jid/src/lib.rs') diff --git a/jid/src/lib.rs b/jid/src/lib.rs index 8f297c6..9301f59 100644 --- a/jid/src/lib.rs +++ b/jid/src/lib.rs @@ -33,6 +33,29 @@ impl Display for JID { } } +#[cfg(feature = "rusqlite")] +impl rusqlite::ToSql for JID { + fn to_sql(&self) -> rusqlite::Result> { + Ok(rusqlite::types::ToSqlOutput::Owned( + rusqlite::types::Value::Text(self.to_string()), + )) + } +} + +#[cfg(feature = "rusqlite")] +impl rusqlite::types::FromSql for JID { + fn column_result(value: rusqlite::types::ValueRef<'_>) -> rusqlite::types::FromSqlResult { + Ok(JID::from_str(value.as_str()?)?) + } +} + +#[cfg(feature = "rusqlite")] +impl From for rusqlite::types::FromSqlError { + fn from(value: ParseError) -> Self { + Self::Other(Box::new(value)) + } +} + #[cfg(feature = "sqlx")] impl sqlx::Type for JID { fn type_info() -> ::TypeInfo { -- cgit