pub struct Connection<'p, P: Sqlite3Api> { /* private fields */ }Expand description
Safe wrapper around a sqlite3* connection.
Implementations§
Source§impl<'p, P: Sqlite3Api> Connection<'p, P>
impl<'p, P: Sqlite3Api> Connection<'p, P>
Sourcepub fn open(
api: &'p P,
filename: &str,
options: OpenOptions<'_>,
) -> Result<Self>
pub fn open( api: &'p P, filename: &str, options: OpenOptions<'_>, ) -> Result<Self>
Open a connection using the provider SPI.
Sourcepub fn prepare(&self, sql: &str) -> Result<Statement<'_, 'p, P>>
pub fn prepare(&self, sql: &str) -> Result<Statement<'_, 'p, P>>
Prepare a statement, using prepare_v3 when available.
Sourcepub fn prepare_with_flags(
&self,
sql: &str,
flags: u32,
) -> Result<Statement<'_, 'p, P>>
pub fn prepare_with_flags( &self, sql: &str, flags: u32, ) -> Result<Statement<'_, 'p, P>>
Prepare a statement with flags (requires prepare_v3 support).
Sourcepub fn raw_handle(&self) -> NonNull<P::Db>
pub fn raw_handle(&self) -> NonNull<P::Db>
Expose the raw database handle.
Source§impl<'p, P: Sqlite3Keying> Connection<'p, P>
impl<'p, P: Sqlite3Keying> Connection<'p, P>
Source§impl<'p, P: Sqlite3Backup> Connection<'p, P>
impl<'p, P: Sqlite3Backup> Connection<'p, P>
Source§impl<'p, P: Sqlite3BlobIo> Connection<'p, P>
impl<'p, P: Sqlite3BlobIo> Connection<'p, P>
Source§impl<'p, P: Sqlite3Serialize> Connection<'p, P>
impl<'p, P: Sqlite3Serialize> Connection<'p, P>
Source§impl<'p, P: Sqlite3Wal> Connection<'p, P>
impl<'p, P: Sqlite3Wal> Connection<'p, P>
Source§impl<'p, P: Sqlite3Metadata> Connection<'p, P>
impl<'p, P: Sqlite3Metadata> Connection<'p, P>
Sourcepub fn table_column_metadata(
&self,
db_name: Option<&str>,
table: &str,
column: &str,
) -> Result<ColumnMetadata>
pub fn table_column_metadata( &self, db_name: Option<&str>, table: &str, column: &str, ) -> Result<ColumnMetadata>
Fetch column metadata for a table.
Source§impl<'p, P: Sqlite3Hooks> Connection<'p, P>
impl<'p, P: Sqlite3Hooks> Connection<'p, P>
Sourcepub fn busy_timeout(&self, ms: i32) -> Result<()>
pub fn busy_timeout(&self, ms: i32) -> Result<()>
Set busy timeout.
Sourcepub unsafe fn progress_handler_raw(
&self,
n: i32,
cb: Option<extern "C" fn(*mut c_void) -> i32>,
context: *mut c_void,
) -> Result<()>
pub unsafe fn progress_handler_raw( &self, n: i32, cb: Option<extern "C" fn(*mut c_void) -> i32>, context: *mut c_void, ) -> Result<()>
Register or clear a raw progress callback.
§Safety
Callers must ensure the callback/context pair remains valid until it is explicitly cleared and that the callback never unwinds.
Sourcepub fn register_progress_handler<'c, F>(
&'c self,
n: i32,
f: F,
) -> Result<CallbackHandle<'c, 'p, P>>
pub fn register_progress_handler<'c, F>( &'c self, n: i32, f: F, ) -> Result<CallbackHandle<'c, 'p, P>>
Register a panic-contained progress callback.
The callback is invoked through a trampoline that catches panics and
returns 1 on unwind so SQLite interrupts execution (fail-closed).
Sourcepub fn clear_progress_handler(&self) -> Result<()>
pub fn clear_progress_handler(&self) -> Result<()>
Remove any previously registered progress callback.
Sourcepub fn register_trace<'c, F>(
&'c self,
mask: TraceMask,
f: F,
) -> Result<CallbackHandle<'c, 'p, P>>
pub fn register_trace<'c, F>( &'c self, mask: TraceMask, f: F, ) -> Result<CallbackHandle<'c, 'p, P>>
Register a typed trace callback.
Register a typed authorizer callback.
Source§impl<'p, P: Sqlite3Api> Connection<'p, P>
impl<'p, P: Sqlite3Api> Connection<'p, P>
Sourcepub fn create_scalar_function<F>(
&self,
name: &str,
n_args: i32,
func: F,
) -> Result<()>
pub fn create_scalar_function<F>( &self, name: &str, n_args: i32, func: F, ) -> Result<()>
Register a scalar function (xFunc).
Sourcepub fn create_aggregate_function<T, Init, Step, Final>(
&self,
name: &str,
n_args: i32,
init: Init,
step: Step,
final_fn: Final,
) -> Result<()>
pub fn create_aggregate_function<T, Init, Step, Final>( &self, name: &str, n_args: i32, init: Init, step: Step, final_fn: Final, ) -> Result<()>
Register an aggregate function (xStep/xFinal).
State is stored out-of-line in a Rust Box<T> and the SQLite aggregate
context keeps only a pointer-sized slot, so T alignment does not
depend on backend aggregate-context allocation alignment.
Sourcepub fn create_window_function<T, Init, Step, Inverse, ValueFn, Final>(
&self,
name: &str,
n_args: i32,
init: Init,
step: Step,
inverse: Inverse,
value_fn: ValueFn,
final_fn: Final,
) -> Result<()>where
T: Send + 'static,
Init: Fn() -> T + Send + 'static,
Step: for<'a> FnMut(&Context<'a, P>, &mut T, &[ValueRef<'a>]) -> Result<()> + Send + 'static,
Inverse: for<'a> FnMut(&Context<'a, P>, &mut T, &[ValueRef<'a>]) -> Result<()> + Send + 'static,
ValueFn: for<'a> FnMut(&Context<'a, P>, &mut T) -> Result<Value> + Send + 'static,
Final: for<'a> FnMut(&Context<'a, P>, T) -> Result<Value> + Send + 'static,
pub fn create_window_function<T, Init, Step, Inverse, ValueFn, Final>(
&self,
name: &str,
n_args: i32,
init: Init,
step: Step,
inverse: Inverse,
value_fn: ValueFn,
final_fn: Final,
) -> Result<()>where
T: Send + 'static,
Init: Fn() -> T + Send + 'static,
Step: for<'a> FnMut(&Context<'a, P>, &mut T, &[ValueRef<'a>]) -> Result<()> + Send + 'static,
Inverse: for<'a> FnMut(&Context<'a, P>, &mut T, &[ValueRef<'a>]) -> Result<()> + Send + 'static,
ValueFn: for<'a> FnMut(&Context<'a, P>, &mut T) -> Result<Value> + Send + 'static,
Final: for<'a> FnMut(&Context<'a, P>, T) -> Result<Value> + Send + 'static,
Register a window function (xStep/xInverse/xValue/xFinal).
State is stored out-of-line in a Rust Box<T> and the SQLite aggregate
context keeps only a pointer-sized slot, so T alignment does not
depend on backend aggregate-context allocation alignment.
Source§impl<'p, P: Sqlite3Api> Connection<'p, P>
impl<'p, P: Sqlite3Api> Connection<'p, P>
Sourcepub fn create_module<T>(&self, name: &str) -> Result<()>
pub fn create_module<T>(&self, name: &str) -> Result<()>
Register a virtual table module using the default glue.