diff options
author | 2025-04-17 17:30:22 +0100 | |
---|---|---|
committer | 2025-04-17 17:30:22 +0100 | |
commit | 61b755c890dcaa66daa35942ca87cc00269b0fe9 (patch) | |
tree | 36190a844cfef474d5e11fe473db462bb4a4d135 /jid | |
parent | 26d0ee51e232b793bc83ba565c0e9ab820d8d0db (diff) | |
download | luz-wasm.tar.gz luz-wasm.tar.bz2 luz-wasm.zip |
feat(filamento): full wasm support by switching to rusqlitewasm
Diffstat (limited to '')
-rw-r--r-- | jid/Cargo.toml | 2 | ||||
-rw-r--r-- | jid/src/lib.rs | 23 |
2 files changed, 25 insertions, 0 deletions
diff --git a/jid/Cargo.toml b/jid/Cargo.toml index e3cf7c7..439ef75 100644 --- a/jid/Cargo.toml +++ b/jid/Cargo.toml @@ -5,9 +5,11 @@ edition = "2021" [features] # default = [] +rusqlite = ["dep:rusqlite"] # sqlx = ["dep:sqlx"] [dependencies] +rusqlite = { git = "https://github.com/Spxg/rusqlite.git", optional = true, branch = "wasm-demo" } # sqlx = { version = "0.8.3", features = ["sqlite"], optional = true } # sqlx = { path = "../../remote/sqlx", features = ["sqlite"], optional = true } 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 { |