Skip to main content

sqlite3_ext/
with_rusqlite.rs

1//! Helpers for when using sqltie3_ext extensions from within Rust programs that use
2//! [rusqlite].
3#![cfg(feature = "with_rusqlite")]
4#![cfg_attr(docsrs, doc(cfg(feature = "with_rusqlite")))]
5
6use super::*;
7
8impl Connection {
9    /// Convert a rusqlite::Connection to an sqlite3_ext::Connection.
10    pub fn from_rusqlite(conn: &rusqlite::Connection) -> &Self {
11        unsafe { Connection::from_ptr(conn.handle() as _) }
12    }
13}
14
15impl From<Error> for rusqlite::Error {
16    fn from(e: Error) -> Self {
17        rusqlite::Error::SqliteFailure(
18            rusqlite::ffi::Error {
19                code: rusqlite::ffi::ErrorCode::Unknown,
20                extended_code: ffi::SQLITE_ERROR,
21            },
22            Some(format!("{}", e)),
23        )
24    }
25}