This commit is contained in:
gwenn 2020-10-28 21:12:29 +01:00
parent 5ce81024c8
commit 76ad2bf19c
7 changed files with 28 additions and 20 deletions

View File

@ -136,7 +136,10 @@
//!
//! // Insert another BLOB, this time using a parameter passed in from
//! // 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
//! let rowid = db.last_insert_rowid();
@ -177,7 +180,10 @@
//!
//! // Insert another blob, this time using a parameter passed in from
//! // 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
//! let rowid = db.last_insert_rowid();
@ -196,8 +202,8 @@ use crate::{Connection, DatabaseName, Result};
mod pos_io;
/// `feature = "blob"` Handle to an open BLOB. See [`rusqlite::blob`](crate::blob) documentation for
/// in-depth discussion.
/// `feature = "blob"` Handle to an open BLOB. See
/// [`rusqlite::blob`](crate::blob) documentation for in-depth discussion.
pub struct Blob<'conn> {
conn: &'conn Connection,
blob: *mut ffi::sqlite3_blob,

View File

@ -111,8 +111,8 @@ pub enum Error {
InvalidParameterCount(usize, usize),
/// Returned from various functions in the Blob IO positional API. For
/// example, [`Blob::raw_read_at_exact`](crate::blob::Blob::raw_read_at_exact)
/// will return it if the blob has insufficient data.
/// example, [`Blob::raw_read_at_exact`](crate::blob::Blob::
/// raw_read_at_exact) will return it if the blob has insufficient data.
#[cfg(feature = "blob")]
BlobSizeError,
}

View File

@ -22,10 +22,9 @@
//! FunctionFlags::SQLITE_UTF8 | FunctionFlags::SQLITE_DETERMINISTIC,
//! move |ctx| {
//! assert_eq!(ctx.len(), 2, "called with unexpected number of arguments");
//! let regexp: Arc<Regex> = ctx
//! .get_or_create_aux(0, |vr| -> Result<_, BoxError> {
//! Ok(Regex::new(vr.as_str()?)?)
//! })?;
//! let regexp: Arc<Regex> = ctx.get_or_create_aux(0, |vr| -> Result<_, BoxError> {
//! Ok(Regex::new(vr.as_str()?)?)
//! })?;
//! let is_match = {
//! let text = ctx
//! .get_raw(1)

View File

@ -77,8 +77,10 @@ impl Connection {
/// `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`.
/// If `num_ops` is less than one then the progress handler is disabled.
/// The parameter `num_ops` is the approximate number of virtual machine
/// 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.
pub fn progress_handler<F>(&self, num_ops: c_int, handler: Option<F>)

View File

@ -20,8 +20,8 @@
//! however you may get a runtime error or rounding depending on the types
//! and values.
//!
//! * `INTEGER` to integer: returns an `Error::IntegralValueOutOfRange` error
//! if the value does not fit.
//! * `INTEGER` to integer: returns an `Error::IntegralValueOutOfRange` error if
//! the value does not fit.
//! * `REAL` to integer: always returns an `Error::InvalidColumnType` error.
//! * `INTEGER` 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
//! [datetime](https://www.sqlite.org/lang_datefunc.html) functions. If you
//! want different storage for datetimes, you can use a newtype.
//!
#![cfg_attr(
feature = "time",
doc = r##"
@ -387,7 +386,7 @@ mod test {
}
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
.insert_statement
.execute(params![$insert_value])
@ -398,7 +397,7 @@ mod test {
assert_eq!(res.unwrap(), $expected_value);
$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
.insert_statement
.execute(params![$insert_value])

View File

@ -100,6 +100,7 @@ impl std::fmt::Debug for SmallCString {
impl std::ops::Deref for SmallCString {
type Target = CStr;
#[inline]
fn deref(&self) -> &CStr {
self.as_cstr()

View File

@ -130,9 +130,10 @@ impl SqliteMallocString {
// This is safe:
// - `align` is never 0
// - `align` is always a power of 2.
// - `size` needs no realignment because it's guaranteed to be
// aligned (everything is aligned to 1)
// - `size` is also never zero, although this function doesn't actually require it now.
// - `size` needs no realignment because it's guaranteed to be aligned
// (everything is aligned to 1)
// - `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);
// Note: This call does not return.
handle_alloc_error(layout);