diff options
author | 2025-04-17 17:30:22 +0100 | |
---|---|---|
committer | 2025-04-17 17:30:22 +0100 | |
commit | 61b755c890dcaa66daa35942ca87cc00269b0fe9 (patch) | |
tree | 36190a844cfef474d5e11fe473db462bb4a4d135 /jid/src/lib.rs | |
parent | 26d0ee51e232b793bc83ba565c0e9ab820d8d0db (diff) | |
download | luz-61b755c890dcaa66daa35942ca87cc00269b0fe9.tar.gz luz-61b755c890dcaa66daa35942ca87cc00269b0fe9.tar.bz2 luz-61b755c890dcaa66daa35942ca87cc00269b0fe9.zip |
feat(filamento): full wasm support by switching to rusqlite
Diffstat (limited to '')
-rw-r--r-- | jid/src/lib.rs | 23 |
1 files changed, 23 insertions, 0 deletions
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<rusqlite::types::ToSqlOutput<'_>> { + 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<Self> { + Ok(JID::from_str(value.as_str()?)?) + } +} + +#[cfg(feature = "rusqlite")] +impl From<ParseError> for rusqlite::types::FromSqlError { + fn from(value: ParseError) -> Self { + Self::Other(Box::new(value)) + } +} + #[cfg(feature = "sqlx")] impl sqlx::Type<Sqlite> for JID { fn type_info() -> <Sqlite as sqlx::Database>::TypeInfo { |