mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-23 00:39:20 +08:00
Rustfmt
This commit is contained in:
parent
5ce81024c8
commit
76ad2bf19c
@ -136,7 +136,10 @@
|
|||||||
//!
|
//!
|
||||||
//! // Insert another BLOB, this time using a parameter passed in from
|
//! // Insert another BLOB, this time using a parameter passed in from
|
||||||
//! // rust (potentially with a dynamic size).
|
//! // rust (potentially with a dynamic size).
|
||||||
//! db.execute("INSERT INTO test_table (content) VALUES (?)", &[ZeroBlob(64)])?;
|
//! db.execute(
|
||||||
|
//! "INSERT INTO test_table (content) VALUES (?)",
|
||||||
|
//! &[ZeroBlob(64)],
|
||||||
|
//! )?;
|
||||||
//!
|
//!
|
||||||
//! // given a new row ID, we can reopen the blob on that row
|
//! // given a new row ID, we can reopen the blob on that row
|
||||||
//! let rowid = db.last_insert_rowid();
|
//! let rowid = db.last_insert_rowid();
|
||||||
@ -177,7 +180,10 @@
|
|||||||
//!
|
//!
|
||||||
//! // Insert another blob, this time using a parameter passed in from
|
//! // Insert another blob, this time using a parameter passed in from
|
||||||
//! // rust (potentially with a dynamic size).
|
//! // rust (potentially with a dynamic size).
|
||||||
//! db.execute("INSERT INTO test_table (content) VALUES (?)", &[ZeroBlob(64)])?;
|
//! db.execute(
|
||||||
|
//! "INSERT INTO test_table (content) VALUES (?)",
|
||||||
|
//! &[ZeroBlob(64)],
|
||||||
|
//! )?;
|
||||||
//!
|
//!
|
||||||
//! // given a new row ID, we can reopen the blob on that row
|
//! // given a new row ID, we can reopen the blob on that row
|
||||||
//! let rowid = db.last_insert_rowid();
|
//! let rowid = db.last_insert_rowid();
|
||||||
@ -196,8 +202,8 @@ use crate::{Connection, DatabaseName, Result};
|
|||||||
|
|
||||||
mod pos_io;
|
mod pos_io;
|
||||||
|
|
||||||
/// `feature = "blob"` Handle to an open BLOB. See [`rusqlite::blob`](crate::blob) documentation for
|
/// `feature = "blob"` Handle to an open BLOB. See
|
||||||
/// in-depth discussion.
|
/// [`rusqlite::blob`](crate::blob) documentation for in-depth discussion.
|
||||||
pub struct Blob<'conn> {
|
pub struct Blob<'conn> {
|
||||||
conn: &'conn Connection,
|
conn: &'conn Connection,
|
||||||
blob: *mut ffi::sqlite3_blob,
|
blob: *mut ffi::sqlite3_blob,
|
||||||
|
@ -111,8 +111,8 @@ pub enum Error {
|
|||||||
InvalidParameterCount(usize, usize),
|
InvalidParameterCount(usize, usize),
|
||||||
|
|
||||||
/// Returned from various functions in the Blob IO positional API. For
|
/// Returned from various functions in the Blob IO positional API. For
|
||||||
/// example, [`Blob::raw_read_at_exact`](crate::blob::Blob::raw_read_at_exact)
|
/// example, [`Blob::raw_read_at_exact`](crate::blob::Blob::
|
||||||
/// will return it if the blob has insufficient data.
|
/// raw_read_at_exact) will return it if the blob has insufficient data.
|
||||||
#[cfg(feature = "blob")]
|
#[cfg(feature = "blob")]
|
||||||
BlobSizeError,
|
BlobSizeError,
|
||||||
}
|
}
|
||||||
|
@ -22,10 +22,9 @@
|
|||||||
//! FunctionFlags::SQLITE_UTF8 | FunctionFlags::SQLITE_DETERMINISTIC,
|
//! FunctionFlags::SQLITE_UTF8 | FunctionFlags::SQLITE_DETERMINISTIC,
|
||||||
//! move |ctx| {
|
//! move |ctx| {
|
||||||
//! assert_eq!(ctx.len(), 2, "called with unexpected number of arguments");
|
//! assert_eq!(ctx.len(), 2, "called with unexpected number of arguments");
|
||||||
//! let regexp: Arc<Regex> = ctx
|
//! let regexp: Arc<Regex> = ctx.get_or_create_aux(0, |vr| -> Result<_, BoxError> {
|
||||||
//! .get_or_create_aux(0, |vr| -> Result<_, BoxError> {
|
//! Ok(Regex::new(vr.as_str()?)?)
|
||||||
//! Ok(Regex::new(vr.as_str()?)?)
|
//! })?;
|
||||||
//! })?;
|
|
||||||
//! let is_match = {
|
//! let is_match = {
|
||||||
//! let text = ctx
|
//! let text = ctx
|
||||||
//! .get_raw(1)
|
//! .get_raw(1)
|
||||||
|
@ -77,8 +77,10 @@ impl Connection {
|
|||||||
|
|
||||||
/// `feature = "hooks"` Register a query progress callback.
|
/// `feature = "hooks"` Register a query progress callback.
|
||||||
///
|
///
|
||||||
/// The parameter `num_ops` is the approximate number of virtual machine instructions that are evaluated between successive invocations of the `handler`.
|
/// The parameter `num_ops` is the approximate number of virtual machine
|
||||||
/// If `num_ops` is less than one then the progress handler is disabled.
|
/// instructions that are evaluated between successive invocations of the
|
||||||
|
/// `handler`. If `num_ops` is less than one then the progress handler
|
||||||
|
/// is disabled.
|
||||||
///
|
///
|
||||||
/// If the progress callback returns `true`, the operation is interrupted.
|
/// If the progress callback returns `true`, the operation is interrupted.
|
||||||
pub fn progress_handler<F>(&self, num_ops: c_int, handler: Option<F>)
|
pub fn progress_handler<F>(&self, num_ops: c_int, handler: Option<F>)
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
//! however you may get a runtime error or rounding depending on the types
|
//! however you may get a runtime error or rounding depending on the types
|
||||||
//! and values.
|
//! and values.
|
||||||
//!
|
//!
|
||||||
//! * `INTEGER` to integer: returns an `Error::IntegralValueOutOfRange` error
|
//! * `INTEGER` to integer: returns an `Error::IntegralValueOutOfRange` error if
|
||||||
//! if the value does not fit.
|
//! the value does not fit.
|
||||||
//! * `REAL` to integer: always returns an `Error::InvalidColumnType` error.
|
//! * `REAL` to integer: always returns an `Error::InvalidColumnType` error.
|
||||||
//! * `INTEGER` to float: casts using `as` operator. Never fails.
|
//! * `INTEGER` to float: casts using `as` operator. Never fails.
|
||||||
//! * `REAL` to float: casts using `as` operator. Never fails.
|
//! * `REAL` to float: casts using `as` operator. Never fails.
|
||||||
@ -32,7 +32,6 @@
|
|||||||
//! can be parsed by SQLite's builtin
|
//! can be parsed by SQLite's builtin
|
||||||
//! [datetime](https://www.sqlite.org/lang_datefunc.html) functions. If you
|
//! [datetime](https://www.sqlite.org/lang_datefunc.html) functions. If you
|
||||||
//! want different storage for datetimes, you can use a newtype.
|
//! want different storage for datetimes, you can use a newtype.
|
||||||
//!
|
|
||||||
#![cfg_attr(
|
#![cfg_attr(
|
||||||
feature = "time",
|
feature = "time",
|
||||||
doc = r##"
|
doc = r##"
|
||||||
@ -387,7 +386,7 @@ mod test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! test_conversion {
|
macro_rules! test_conversion {
|
||||||
($db_etc:ident, $insert_value:expr, $get_type:ty, expect $expected_value:expr) => {
|
($db_etc:ident, $insert_value:expr, $get_type:ty,expect $expected_value:expr) => {
|
||||||
$db_etc
|
$db_etc
|
||||||
.insert_statement
|
.insert_statement
|
||||||
.execute(params![$insert_value])
|
.execute(params![$insert_value])
|
||||||
@ -398,7 +397,7 @@ mod test {
|
|||||||
assert_eq!(res.unwrap(), $expected_value);
|
assert_eq!(res.unwrap(), $expected_value);
|
||||||
$db_etc.delete_statement.execute(NO_PARAMS).unwrap();
|
$db_etc.delete_statement.execute(NO_PARAMS).unwrap();
|
||||||
};
|
};
|
||||||
($db_etc:ident, $insert_value:expr, $get_type:ty, expect_error) => {
|
($db_etc:ident, $insert_value:expr, $get_type:ty,expect_error) => {
|
||||||
$db_etc
|
$db_etc
|
||||||
.insert_statement
|
.insert_statement
|
||||||
.execute(params![$insert_value])
|
.execute(params![$insert_value])
|
||||||
|
@ -100,6 +100,7 @@ impl std::fmt::Debug for SmallCString {
|
|||||||
|
|
||||||
impl std::ops::Deref for SmallCString {
|
impl std::ops::Deref for SmallCString {
|
||||||
type Target = CStr;
|
type Target = CStr;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn deref(&self) -> &CStr {
|
fn deref(&self) -> &CStr {
|
||||||
self.as_cstr()
|
self.as_cstr()
|
||||||
|
@ -130,9 +130,10 @@ impl SqliteMallocString {
|
|||||||
// This is safe:
|
// This is safe:
|
||||||
// - `align` is never 0
|
// - `align` is never 0
|
||||||
// - `align` is always a power of 2.
|
// - `align` is always a power of 2.
|
||||||
// - `size` needs no realignment because it's guaranteed to be
|
// - `size` needs no realignment because it's guaranteed to be aligned
|
||||||
// aligned (everything is aligned to 1)
|
// (everything is aligned to 1)
|
||||||
// - `size` is also never zero, although this function doesn't actually require it now.
|
// - `size` is also never zero, although this function doesn't actually require
|
||||||
|
// it now.
|
||||||
let layout = Layout::from_size_align_unchecked(s.len().saturating_add(1), 1);
|
let layout = Layout::from_size_align_unchecked(s.len().saturating_add(1), 1);
|
||||||
// Note: This call does not return.
|
// Note: This call does not return.
|
||||||
handle_alloc_error(layout);
|
handle_alloc_error(layout);
|
||||||
|
Loading…
Reference in New Issue
Block a user