mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-26 11:31:37 +08:00
Merge remote-tracking branch 'origin/master' into doc_cfg
This commit is contained in:
commit
2ddbebad97
@ -223,7 +223,7 @@ impl Connection {
|
||||
row_id: i64,
|
||||
read_only: bool,
|
||||
) -> Result<Blob<'a>> {
|
||||
let mut c = self.db.borrow_mut();
|
||||
let c = self.db.borrow_mut();
|
||||
let mut blob = ptr::null_mut();
|
||||
let db = db.as_cstring()?;
|
||||
let table = super::str_to_cstring(table)?;
|
||||
|
@ -64,7 +64,7 @@ impl Connection {
|
||||
0
|
||||
}
|
||||
}
|
||||
let mut c = self.db.borrow_mut();
|
||||
let c = self.db.borrow_mut();
|
||||
let r = match callback {
|
||||
Some(f) => unsafe {
|
||||
ffi::sqlite3_busy_handler(c.db(), Some(busy_handler_callback), f as *mut c_void)
|
||||
|
11
src/hooks.rs
11
src/hooks.rs
@ -14,7 +14,6 @@ use crate::{Connection, InnerConnection};
|
||||
#[repr(i32)]
|
||||
#[non_exhaustive]
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "hooks")))]
|
||||
pub enum Action {
|
||||
/// Unsupported / unexpected action
|
||||
UNKNOWN = -1,
|
||||
@ -43,14 +42,14 @@ impl From<i32> for Action {
|
||||
/// See <https://sqlite.org/c3ref/set_authorizer.html> for more info.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct AuthContext<'c> {
|
||||
// The action to be authorized.
|
||||
/// The action to be authorized.
|
||||
pub action: AuthAction<'c>,
|
||||
|
||||
/// The database name, if applicable.
|
||||
pub database_name: Option<&'c str>,
|
||||
|
||||
// The inner-most trigger or view responsible for the access attempt.
|
||||
// `None` if the access attempt was made by top-level SQL code.
|
||||
/// The inner-most trigger or view responsible for the access attempt.
|
||||
/// `None` if the access attempt was made by top-level SQL code.
|
||||
pub accessor: Option<&'c str>,
|
||||
}
|
||||
|
||||
@ -299,6 +298,7 @@ pub(crate) type BoxedAuthorizer =
|
||||
/// A transaction operation.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[non_exhaustive]
|
||||
#[allow(missing_docs)]
|
||||
pub enum TransactionOperation {
|
||||
Unknown,
|
||||
Begin,
|
||||
@ -317,6 +317,7 @@ impl TransactionOperation {
|
||||
}
|
||||
}
|
||||
|
||||
/// [`authorizer`](Connection::authorizer) return code
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[non_exhaustive]
|
||||
pub enum Authorization {
|
||||
@ -598,7 +599,7 @@ impl InnerConnection {
|
||||
};
|
||||
}
|
||||
|
||||
pub fn authorizer<'c, F>(&'c mut self, authorizer: Option<F>)
|
||||
fn authorizer<'c, F>(&'c mut self, authorizer: Option<F>)
|
||||
where
|
||||
F: for<'r> FnMut(AuthContext<'r>) -> Authorization + Send + RefUnwindSafe + 'static,
|
||||
{
|
||||
|
@ -136,7 +136,7 @@ impl InnerConnection {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn decode_result(&mut self, code: c_int) -> Result<()> {
|
||||
pub fn decode_result(&self, code: c_int) -> Result<()> {
|
||||
unsafe { InnerConnection::decode_result_raw(self.db(), code) }
|
||||
}
|
||||
|
||||
@ -278,7 +278,7 @@ impl InnerConnection {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn changes(&mut self) -> usize {
|
||||
pub fn changes(&self) -> usize {
|
||||
unsafe { ffi::sqlite3_changes(self.db()) as usize }
|
||||
}
|
||||
|
||||
|
@ -74,8 +74,6 @@ pub use crate::cache::CachedStatement;
|
||||
pub use crate::column::Column;
|
||||
pub use crate::error::Error;
|
||||
pub use crate::ffi::ErrorCode;
|
||||
#[cfg(feature = "hooks")]
|
||||
pub use crate::hooks::Action;
|
||||
#[cfg(feature = "load_extension")]
|
||||
pub use crate::load_extension_guard::LoadExtensionGuard;
|
||||
pub use crate::params::{params_from_iter, Params, ParamsFromIter};
|
||||
@ -108,7 +106,7 @@ mod context;
|
||||
pub mod functions;
|
||||
#[cfg(feature = "hooks")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "hooks")))]
|
||||
mod hooks;
|
||||
pub mod hooks;
|
||||
mod inner_connection;
|
||||
#[cfg(feature = "limits")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "limits")))]
|
||||
@ -845,7 +843,7 @@ impl Connection {
|
||||
|
||||
#[inline]
|
||||
fn decode_result(&self, code: c_int) -> Result<()> {
|
||||
self.db.borrow_mut().decode_result(code)
|
||||
self.db.borrow().decode_result(code)
|
||||
}
|
||||
|
||||
/// Return the number of rows modified, inserted or deleted by the most
|
||||
@ -853,7 +851,7 @@ impl Connection {
|
||||
/// connection.
|
||||
#[inline]
|
||||
fn changes(&self) -> usize {
|
||||
self.db.borrow_mut().changes()
|
||||
self.db.borrow().changes()
|
||||
}
|
||||
|
||||
/// Test for auto-commit mode.
|
||||
|
Loading…
Reference in New Issue
Block a user