Skip to main content

LibSqlite3

Struct LibSqlite3 

Source
pub struct LibSqlite3 { /* private fields */ }
Expand description

Dynamic libsqlite3 backend adapter loaded via dlopen.

Implementations§

Source§

impl LibSqlite3

Source

pub fn load() -> Option<&'static LibSqlite3>

Load libsqlite3 and return a process-wide adapter instance.

Returns None if the library or required symbols are unavailable.

Source

pub unsafe fn abi_db_filename( &self, db: *mut c_void, name: Option<&str>, ) -> Option<RawBytes>

ABI helper: sqlite3_db_filename.

The returned bytes are backend-managed and follow SQLite pointer lifetime rules.

§Safety

db must be a valid sqlite3* from this loaded backend, and must remain valid for the duration of the call.

Source

pub unsafe fn abi_get_autocommit(&self, db: *mut c_void) -> i32

ABI helper: sqlite3_get_autocommit.

§Safety

db must be a valid sqlite3* from this loaded backend.

Source

pub unsafe fn abi_total_changes(&self, db: *mut c_void) -> i32

ABI helper: sqlite3_total_changes.

§Safety

db must be a valid sqlite3* from this loaded backend.

Source

pub unsafe fn abi_changes(&self, db: *mut c_void) -> i32

ABI helper: sqlite3_changes.

§Safety

db must be a valid sqlite3* from this loaded backend.

Source

pub unsafe fn abi_changes64(&self, db: *mut c_void) -> i64

ABI helper: sqlite3_changes64.

§Safety

db must be a valid sqlite3* from this loaded backend.

Source

pub unsafe fn abi_last_insert_rowid(&self, db: *mut c_void) -> i64

ABI helper: sqlite3_last_insert_rowid.

§Safety

db must be a valid sqlite3* from this loaded backend.

Source

pub unsafe fn abi_interrupt(&self, db: *mut c_void)

ABI helper: sqlite3_interrupt.

§Safety

db must be a valid sqlite3* from this loaded backend.

Source

pub unsafe fn abi_db_config(&self, db: *mut c_void, op: i32) -> i32

ABI helper: sqlite3_db_config.

§Safety

db must be a valid sqlite3* from this loaded backend.

Source

pub unsafe fn abi_limit(&self, db: *mut c_void, id: i32, new_value: i32) -> i32

ABI helper: sqlite3_limit.

§Safety

db must be a valid sqlite3* from this loaded backend.

Source

pub unsafe fn abi_stmt_readonly(&self, stmt: *mut c_void) -> i32

ABI helper: sqlite3_stmt_readonly.

§Safety

stmt must be a valid sqlite3_stmt* from this loaded backend.

Source

pub unsafe fn abi_stmt_busy(&self, stmt: *mut c_void) -> i32

ABI helper: sqlite3_stmt_busy.

§Safety

stmt must be a valid sqlite3_stmt* from this loaded backend.

Source

pub unsafe fn abi_bind_parameter_count(&self, stmt: *mut c_void) -> i32

ABI helper: sqlite3_bind_parameter_count.

§Safety

stmt must be a valid sqlite3_stmt* from this loaded backend.

Source

pub unsafe fn abi_bind_parameter_name( &self, stmt: *mut c_void, idx: i32, ) -> Option<RawBytes>

ABI helper: sqlite3_bind_parameter_name.

The returned bytes are backend-managed and follow SQLite pointer lifetime rules.

§Safety

stmt must be a valid sqlite3_stmt* from this loaded backend.

Source

pub unsafe fn abi_bind_parameter_index( &self, stmt: *mut c_void, name: &str, ) -> i32

ABI helper: sqlite3_bind_parameter_index.

§Safety

stmt must be a valid sqlite3_stmt* from this loaded backend.

Source

pub unsafe fn abi_context_db_handle( &self, ctx: *mut c_void, ) -> Option<NonNull<c_void>>

ABI helper: sqlite3_context_db_handle.

§Safety

ctx must be a valid sqlite3_context* provided by SQLite for an active scalar/aggregate/window callback.

Trait Implementations§

Source§

impl Sqlite3Api for LibSqlite3

Source§

type Db = c_void

Backend’s opaque sqlite3* type.
Source§

type Stmt = c_void

Backend’s opaque sqlite3_stmt* type.
Source§

type Value = c_void

Backend’s opaque sqlite3_value* type.
Source§

type Context = c_void

Backend’s opaque sqlite3_context* type.
Source§

type VTab = c_void

Backend’s opaque sqlite3_vtab* type.
Source§

type VTabCursor = c_void

Backend’s opaque sqlite3_vtab_cursor* type.
Source§

fn api_version(&self) -> ApiVersion

Declared SQLite API version supported by this provider implementation.
Source§

fn feature_set(&self) -> FeatureSet

Compile/runtime capability flags available through this provider.
Source§

fn backend_name(&self) -> &'static str

Stable backend identifier (for diagnostics and capability routing).
Source§

fn backend_version(&self) -> Option<ApiVersion>

Optional backend runtime version (if queryable).
Source§

unsafe fn malloc(&self, size: usize) -> *mut c_void

Return SQLite allocator-compatible memory for cross-FFI ownership. Read more
Source§

unsafe fn free(&self, ptr: *mut c_void)

Free memory allocated through malloc.
Source§

fn threadsafe(&self) -> i32

Thread-safety capability in sqlite3_threadsafe() form.
Source§

unsafe fn open( &self, filename: &str, options: OpenOptions<'_>, ) -> Result<NonNull<Self::Db>>

Open a database connection using backend-specific open_v2 semantics.
Source§

unsafe fn close(&self, db: NonNull<Self::Db>) -> Result<()>

Close a database connection handle.
Source§

unsafe fn prepare_v2( &self, db: NonNull<Self::Db>, sql: &str, ) -> Result<NonNull<Self::Stmt>>

Prepare SQL using legacy prepare_v2 behavior.
Source§

unsafe fn prepare_v3( &self, db: NonNull<Self::Db>, sql: &str, flags: u32, ) -> Result<NonNull<Self::Stmt>>

Prepare SQL with prepare_v3 flags.
Source§

unsafe fn step(&self, stmt: NonNull<Self::Stmt>) -> Result<StepResult>

Execute one step of the virtual machine.
Source§

unsafe fn reset(&self, stmt: NonNull<Self::Stmt>) -> Result<()>

Reset a prepared statement to run again.
Source§

unsafe fn finalize(&self, stmt: NonNull<Self::Stmt>) -> Result<()>

Finalize a prepared statement and release backend resources.
Source§

unsafe fn bind_null(&self, stmt: NonNull<Self::Stmt>, idx: i32) -> Result<()>

Bind SQL NULL at parameter index idx (1-based).
Source§

unsafe fn bind_int64( &self, stmt: NonNull<Self::Stmt>, idx: i32, v: i64, ) -> Result<()>

Bind 64-bit integer at parameter index idx (1-based).
Source§

unsafe fn bind_double( &self, stmt: NonNull<Self::Stmt>, idx: i32, v: f64, ) -> Result<()>

Bind floating value at parameter index idx (1-based).
Source§

unsafe fn bind_text( &self, stmt: NonNull<Self::Stmt>, idx: i32, v: &str, ) -> Result<()>

Bind UTF-8 text at parameter index idx (1-based). Read more
Source§

unsafe fn bind_text_bytes( &self, stmt: NonNull<Self::Stmt>, idx: i32, v: &[u8], ) -> Result<()>

Bind text bytes at parameter index idx (1-based). Read more
Source§

unsafe fn bind_blob( &self, stmt: NonNull<Self::Stmt>, idx: i32, v: &[u8], ) -> Result<()>

Bind bytes at parameter index idx (1-based). Read more
Source§

unsafe fn column_count(&self, stmt: NonNull<Self::Stmt>) -> i32

Number of columns in the current result row.
Source§

unsafe fn column_type(&self, stmt: NonNull<Self::Stmt>, col: i32) -> ValueType

SQLite storage class for col in the current row.
Source§

unsafe fn column_int64(&self, stmt: NonNull<Self::Stmt>, col: i32) -> i64

Integer value for col in the current row.
Source§

unsafe fn column_double(&self, stmt: NonNull<Self::Stmt>, col: i32) -> f64

Floating value for col in the current row.
Source§

unsafe fn column_text(&self, stmt: NonNull<Self::Stmt>, col: i32) -> RawBytes

Raw text bytes for col in the current row snapshot.
Source§

unsafe fn column_blob(&self, stmt: NonNull<Self::Stmt>, col: i32) -> RawBytes

Raw blob bytes for col in the current row snapshot.
Source§

unsafe fn errcode(&self, db: NonNull<Self::Db>) -> i32

Primary SQLite result code for a connection.
Source§

unsafe fn errmsg(&self, db: NonNull<Self::Db>) -> *const c_char

Backend-provided UTF-8 error message pointer for a connection.
Source§

unsafe fn extended_errcode(&self, db: NonNull<Self::Db>) -> Option<i32>

Extended SQLite result code, if supported.
Source§

unsafe fn create_function_v2( &self, db: NonNull<Self::Db>, name: &str, n_args: i32, flags: FunctionFlags, x_func: Option<extern "C" fn(*mut Self::Context, i32, *mut *mut Self::Value)>, x_step: Option<extern "C" fn(*mut Self::Context, i32, *mut *mut Self::Value)>, x_final: Option<extern "C" fn(*mut Self::Context)>, user_data: *mut c_void, drop_user_data: Option<extern "C" fn(*mut c_void)>, ) -> Result<()>

Register scalar/aggregate callbacks. Read more
Source§

unsafe fn create_window_function( &self, db: NonNull<Self::Db>, name: &str, n_args: i32, flags: FunctionFlags, x_step: Option<extern "C" fn(*mut Self::Context, i32, *mut *mut Self::Value)>, x_final: Option<extern "C" fn(*mut Self::Context)>, x_value: Option<extern "C" fn(*mut Self::Context)>, x_inverse: Option<extern "C" fn(*mut Self::Context, i32, *mut *mut Self::Value)>, user_data: *mut c_void, drop_user_data: Option<extern "C" fn(*mut c_void)>, ) -> Result<()>

Register window-function callbacks. Read more
Source§

unsafe fn create_collation_v2( &self, db: NonNull<Self::Db>, name: &str, enc: i32, context: *mut c_void, cmp: Option<extern "C" fn(*mut c_void, i32, *const c_void, i32, *const c_void) -> i32>, destroy: Option<extern "C" fn(*mut c_void)>, ) -> Result<()>

Register or replace a collation sequence. Read more
Source§

unsafe fn aggregate_context( &self, ctx: NonNull<Self::Context>, bytes: usize, ) -> *mut c_void

Fetch or allocate aggregate state memory for ctx.
Source§

unsafe fn result_null(&self, ctx: NonNull<Self::Context>)

Set current function result to NULL.
Source§

unsafe fn result_int64(&self, ctx: NonNull<Self::Context>, v: i64)

Set current function result to integer.
Source§

unsafe fn result_double(&self, ctx: NonNull<Self::Context>, v: f64)

Set current function result to floating value.
Source§

unsafe fn result_text(&self, ctx: NonNull<Self::Context>, v: &str)

Providers must ensure SQLite copies or retains the buffer for v.
Source§

unsafe fn result_text_bytes(&self, ctx: NonNull<Self::Context>, v: &[u8])

Providers must ensure SQLite copies or retains the buffer for v. Read more
Source§

unsafe fn result_blob(&self, ctx: NonNull<Self::Context>, v: &[u8])

Providers must ensure SQLite copies or retains the buffer for v.
Source§

unsafe fn result_error(&self, ctx: NonNull<Self::Context>, msg: &str)

Set current function result to an error message.
Source§

unsafe fn user_data(ctx: NonNull<Self::Context>) -> *mut c_void

Return function user_data for ctx.
Source§

unsafe fn value_type(&self, v: NonNull<Self::Value>) -> ValueType

SQLite storage class of a UDF argument value.
Source§

unsafe fn value_int64(&self, v: NonNull<Self::Value>) -> i64

Integer view of a UDF argument value.
Source§

unsafe fn value_double(&self, v: NonNull<Self::Value>) -> f64

Floating view of a UDF argument value.
Source§

unsafe fn value_text(&self, v: NonNull<Self::Value>) -> RawBytes

Raw text bytes view of a UDF argument value.
Source§

unsafe fn value_blob(&self, v: NonNull<Self::Value>) -> RawBytes

Raw blob bytes view of a UDF argument value.
Source§

unsafe fn declare_vtab(&self, db: NonNull<Self::Db>, schema: &str) -> Result<()>

Declare a virtual table schema during xCreate/xConnect.
Source§

unsafe fn create_module_v2( &self, db: NonNull<Self::Db>, name: &str, module: &'static sqlite3_module<Self>, user_data: *mut c_void, drop_user_data: Option<extern "C" fn(*mut c_void)>, ) -> Result<()>

Register a virtual table module.
Source§

impl Sqlite3Backup for LibSqlite3

Source§

type Backup = c_void

Backend-specific backup-handle type.
Source§

unsafe fn backup_init( &self, dest_db: NonNull<Self::Db>, dest_name: &str, source_db: NonNull<Self::Db>, source_name: &str, ) -> Result<NonNull<Self::Backup>>

Start a backup from source_db/source_name into dest_db/dest_name.
Source§

unsafe fn backup_step( &self, backup: NonNull<Self::Backup>, pages: i32, ) -> Result<()>

Copy up to pages pages from source to destination.
Source§

unsafe fn backup_remaining(&self, backup: NonNull<Self::Backup>) -> i32

Return the number of pages still remaining.
Source§

unsafe fn backup_pagecount(&self, backup: NonNull<Self::Backup>) -> i32

Return the total page count of the source database.
Source§

unsafe fn backup_finish(&self, backup: NonNull<Self::Backup>) -> Result<()>

Finish and release a backup handle.
Source§

impl Sqlite3BlobIo for LibSqlite3

Source§

type Blob = c_void

Backend-specific incremental-blob handle type.
Source§

unsafe fn blob_open( &self, db: NonNull<Self::Db>, db_name: &str, table: &str, column: &str, rowid: i64, flags: u32, ) -> Result<NonNull<Self::Blob>>

Open an incremental blob handle for a row/column cell.
Source§

unsafe fn blob_read( &self, blob: NonNull<Self::Blob>, data: &mut [u8], offset: i32, ) -> Result<()>

Read bytes from blob into data starting at offset.
Source§

unsafe fn blob_write( &self, blob: NonNull<Self::Blob>, data: &[u8], offset: i32, ) -> Result<()>

Write data into blob starting at offset.
Source§

unsafe fn blob_bytes(&self, blob: NonNull<Self::Blob>) -> i32

Return blob size in bytes.
Source§

unsafe fn blob_close(&self, blob: NonNull<Self::Blob>) -> Result<()>

Close and release a blob handle.
Source§

impl Sqlite3Hooks for LibSqlite3

Source§

unsafe fn trace_v2( &self, db: NonNull<Self::Db>, mask: u32, callback: Option<extern "C" fn(u32, *mut c_void, *mut c_void, *mut c_void)>, context: *mut c_void, ) -> Result<()>

Register or clear a sqlite3_trace_v2 callback.
Source§

unsafe fn progress_handler( &self, db: NonNull<Self::Db>, n: i32, callback: Option<extern "C" fn(*mut c_void) -> i32>, context: *mut c_void, ) -> Result<()>

Register or clear a progress handler callback.
Source§

unsafe fn busy_timeout(&self, db: NonNull<Self::Db>, ms: i32) -> Result<()>

Set busy timeout in milliseconds.
Source§

unsafe fn set_authorizer( &self, db: NonNull<Self::Db>, callback: Option<extern "C" fn(*mut c_void, i32, *const c_char, *const c_char, *const c_char, *const c_char) -> i32>, context: *mut c_void, ) -> Result<()>

Register or clear an authorizer callback.
Source§

impl Sqlite3Metadata for LibSqlite3

Source§

unsafe fn table_column_metadata( &self, db: NonNull<Self::Db>, db_name: Option<&str>, table: &str, column: &str, ) -> Result<ColumnMetadata>

Query table/column metadata for the specified schema object.
Source§

unsafe fn column_decltype( &self, stmt: NonNull<Self::Stmt>, col: i32, ) -> Option<RawBytes>

Return declared type text for output column col.
Source§

unsafe fn column_name( &self, stmt: NonNull<Self::Stmt>, col: i32, ) -> Option<RawBytes>

Return output column name for col.
Source§

unsafe fn column_table_name( &self, stmt: NonNull<Self::Stmt>, col: i32, ) -> Option<RawBytes>

Return source table name for output column col, when available.
Source§

impl Sqlite3Serialize for LibSqlite3

Source§

unsafe fn serialize( &self, db: NonNull<Self::Db>, schema: Option<&str>, flags: u32, ) -> Result<OwnedBytes>

Serialize a schema database into backend-owned bytes.
Source§

unsafe fn deserialize( &self, db: NonNull<Self::Db>, schema: Option<&str>, data: &[u8], flags: u32, ) -> Result<()>

Replace schema contents from caller-owned bytes.
Source§

unsafe fn free(&self, bytes: OwnedBytes)

Free serialized bytes previously returned by serialize.
Source§

impl Sqlite3Wal for LibSqlite3

Source§

unsafe fn wal_checkpoint( &self, db: NonNull<Self::Db>, db_name: Option<&str>, ) -> Result<()>

Run a passive checkpoint for db_name (or main when None).
Source§

unsafe fn wal_checkpoint_v2( &self, db: NonNull<Self::Db>, db_name: Option<&str>, mode: i32, ) -> Result<(i32, i32)>

Run checkpoint mode mode, returning (log_frames, checkpointed_frames).
Source§

unsafe fn wal_frame_count(&self, db: NonNull<Self::Db>) -> Result<Option<u32>>

Return backend-specific WAL frame count when supported.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.