Merge pull request #848 from gwenn/doc_link

Add/fix rustdoc links
This commit is contained in:
gwenn 2020-11-22 17:41:59 +01:00 committed by GitHub
commit 5f16886b61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 97 additions and 108 deletions

View File

@ -31,7 +31,7 @@ fn main() -> Result<()> {
name TEXT NOT NULL, name TEXT NOT NULL,
data BLOB data BLOB
)", )",
params![], [],
)?; )?;
let me = Person { let me = Person {
id: 0, id: 0,
@ -44,7 +44,7 @@ fn main() -> Result<()> {
)?; )?;
let mut stmt = conn.prepare("SELECT id, name, data FROM person")?; let mut stmt = conn.prepare("SELECT id, name, data FROM person")?;
let person_iter = stmt.query_map(params![], |row| { let person_iter = stmt.query_map([], |row| {
Ok(Person { Ok(Person {
id: row.get(0)?, id: row.get(0)?,
name: row.get(1)?, name: row.get(1)?,

View File

@ -1,11 +1,11 @@
//! `feature = "backup"` Online SQLite backup API. //! `feature = "backup"` Online SQLite backup API.
//! //!
//! To create a `Backup`, you must have two distinct `Connection`s - one //! To create a [`Backup`], you must have two distinct [`Connection`]s - one
//! for the source (which can be used while the backup is running) and one for //! for the source (which can be used while the backup is running) and one for
//! the destination (which cannot). A `Backup` handle exposes three methods: //! the destination (which cannot). A [`Backup`] handle exposes three methods:
//! `step` will attempt to back up a specified number of pages, `progress` gets //! [`step`](Backup::step) will attempt to back up a specified number of pages, [`progress`](Backup::progress) gets
//! the current progress of the backup as of the last call to `step`, and //! the current progress of the backup as of the last call to [`step`](Backup::step), and
//! `run_to_completion` will attempt to back up the entire source database, //! [`run_to_completion`](Backup::run_to_completion) will attempt to back up the entire source database,
//! allowing you to specify how many pages are backed up at a time and how long //! allowing you to specify how many pages are backed up at a time and how long
//! the thread should sleep between chunks of pages. //! the thread should sleep between chunks of pages.
//! //!
@ -130,7 +130,7 @@ impl Connection {
} }
} }
/// `feature = "backup"` Possible successful results of calling `Backup::step`. /// `feature = "backup"` Possible successful results of calling [`Backup::step`].
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[non_exhaustive] #[non_exhaustive]
pub enum StepResult { pub enum StepResult {
@ -152,8 +152,8 @@ pub enum StepResult {
/// `feature = "backup"` Struct specifying the progress of a backup. The /// `feature = "backup"` Struct specifying the progress of a backup. The
/// percentage completion can be calculated as `(pagecount - remaining) / /// percentage completion can be calculated as `(pagecount - remaining) /
/// pagecount`. The progress of a backup is as of the last call to `step` - if /// pagecount`. The progress of a backup is as of the last call to [`step`](Backup::step) - if
/// the source database is modified after a call to `step`, the progress value /// the source database is modified after a call to [`step`](Backup::step), the progress value
/// will become outdated and potentially incorrect. /// will become outdated and potentially incorrect.
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub struct Progress { pub struct Progress {
@ -225,7 +225,7 @@ impl Backup<'_, '_> {
}) })
} }
/// Gets the progress of the backup as of the last call to `step`. /// Gets the progress of the backup as of the last call to [`step`](Backup::step).
#[inline] #[inline]
pub fn progress(&self) -> Progress { pub fn progress(&self) -> Progress {
unsafe { unsafe {
@ -240,7 +240,7 @@ impl Backup<'_, '_> {
/// negative, will attempt to back up all remaining pages. This will hold a /// negative, will attempt to back up all remaining pages. This will hold a
/// lock on the source database for the duration, so it is probably not /// lock on the source database for the duration, so it is probably not
/// what you want for databases that are currently active (see /// what you want for databases that are currently active (see
/// `run_to_completion` for a better alternative). /// [`run_to_completion`](Backup::run_to_completion) for a better alternative).
/// ///
/// # Failure /// # Failure
/// ///
@ -262,7 +262,7 @@ impl Backup<'_, '_> {
} }
} }
/// Attempts to run the entire backup. Will call `step(pages_per_step)` as /// Attempts to run the entire backup. Will call [`step(pages_per_step)`](Backup::step) as
/// many times as necessary, sleeping for `pause_between_pages` between /// many times as necessary, sleeping for `pause_between_pages` between
/// each call to give the source database time to process any pending /// each call to give the source database time to process any pending
/// queries. This is a direct implementation of "Example 2: Online Backup /// queries. This is a direct implementation of "Example 2: Online Backup
@ -276,7 +276,7 @@ impl Backup<'_, '_> {
/// ///
/// # Failure /// # Failure
/// ///
/// Will return `Err` if any of the calls to `step` return `Err`. /// Will return `Err` if any of the calls to [`step`](Backup::step) return `Err`.
pub fn run_to_completion( pub fn run_to_completion(
&self, &self,
pages_per_step: c_int, pages_per_step: c_int,

View File

@ -47,7 +47,7 @@
//! functions take a `&mut [MaybeUninit<u8>]` as the destination buffer, //! functions take a `&mut [MaybeUninit<u8>]` as the destination buffer,
//! where the "normal" functions take a `&mut [u8]`. //! where the "normal" functions take a `&mut [u8]`.
//! //!
//! Using `MaybeUninit` here can be more efficient in some cases, but is //! Using `MaybeUninit` here can be more efficient in some cases, but is
//! often inconvenient, so both are provided. //! often inconvenient, so both are provided.
//! //!
//! 2. Exact/inexact refers to to whether or not the entire buffer must be //! 2. Exact/inexact refers to to whether or not the entire buffer must be

View File

@ -19,7 +19,7 @@ impl Connection {
/// ///
/// There can only be a single busy handler for a particular database /// There can only be a single busy handler for a particular database
/// connection at any given moment. If another busy handler was defined /// connection at any given moment. If another busy handler was defined
/// (using `busy_handler`) prior to calling this routine, that other /// (using [`busy_handler`](Connection::busy_handler)) prior to calling this routine, that other
/// busy handler is cleared. /// busy handler is cleared.
pub fn busy_timeout(&self, timeout: Duration) -> Result<()> { pub fn busy_timeout(&self, timeout: Duration) -> Result<()> {
let ms: i32 = timeout let ms: i32 = timeout
@ -45,7 +45,7 @@ impl Connection {
/// ///
/// There can only be a single busy handler defined for each database /// There can only be a single busy handler defined for each database
/// connection. Setting a new busy handler clears any previously set /// connection. Setting a new busy handler clears any previously set
/// handler. Note that calling `busy_timeout()` or evaluating `PRAGMA /// handler. Note that calling [`busy_timeout()`](Connection::busy_timeout) or evaluating `PRAGMA
/// busy_timeout=N` will change the busy handler and thus /// busy_timeout=N` will change the busy handler and thus
/// clear any previously set busy handler. /// clear any previously set busy handler.
pub fn busy_handler(&self, callback: Option<fn(i32) -> bool>) -> Result<()> { pub fn busy_handler(&self, callback: Option<fn(i32) -> bool>) -> Result<()> {

View File

@ -11,7 +11,7 @@ impl Connection {
/// Prepare a SQL statement for execution, returning a previously prepared /// Prepare a SQL statement for execution, returning a previously prepared
/// (but not currently in-use) statement if one is available. The /// (but not currently in-use) statement if one is available. The
/// returned statement will be cached for reuse by future calls to /// returned statement will be cached for reuse by future calls to
/// `prepare_cached` once it is dropped. /// [`prepare_cached`](Connection::prepare_cached) once it is dropped.
/// ///
/// ```rust,no_run /// ```rust,no_run
/// # use rusqlite::{Connection, Result}; /// # use rusqlite::{Connection, Result};
@ -63,7 +63,7 @@ pub struct StatementCache(RefCell<LruCache<Arc<str>, RawStatement>>);
/// Cacheable statement. /// Cacheable statement.
/// ///
/// Statement will return automatically to the cache by default. /// Statement will return automatically to the cache by default.
/// If you want the statement to be discarded, call `discard()` on it. /// If you want the statement to be discarded, call [`discard()`](CachedStatement::discard) on it.
pub struct CachedStatement<'conn> { pub struct CachedStatement<'conn> {
stmt: Option<Statement<'conn>>, stmt: Option<Statement<'conn>>,
cache: &'conn StatementCache, cache: &'conn StatementCache,
@ -105,7 +105,7 @@ impl CachedStatement<'_> {
} }
/// Discard the statement, preventing it from being returned to its /// Discard the statement, preventing it from being returned to its
/// `Connection`'s collection of cached statements. /// [`Connection`]'s collection of cached statements.
#[inline] #[inline]
pub fn discard(mut self) { pub fn discard(mut self) {
self.stmt = None; self.stmt = None;

View File

@ -43,11 +43,11 @@ pub enum Error {
/// Error converting a file path to a string. /// Error converting a file path to a string.
InvalidPath(PathBuf), InvalidPath(PathBuf),
/// Error returned when an `execute` call returns rows. /// Error returned when an [`execute`](crate::Connection::execute) call returns rows.
ExecuteReturnedResults, ExecuteReturnedResults,
/// Error when a query that was expected to return at least one row (e.g., /// Error when a query that was expected to return at least one row (e.g.,
/// for `query_row`) did not return any. /// for [`query_row`](crate::Connection::query_row)) did not return any.
QueryReturnedNoRows, QueryReturnedNoRows,
/// Error when the value of a particular column is requested, but the index /// Error when the value of a particular column is requested, but the index
@ -67,29 +67,29 @@ pub enum Error {
/// any or insert many. /// any or insert many.
StatementChangedRows(usize), StatementChangedRows(usize),
/// Error returned by `functions::Context::get` when the function argument /// Error returned by [`functions::Context::get`](crate::functions::Context::get) when the function argument
/// cannot be converted to the requested type. /// cannot be converted to the requested type.
#[cfg(feature = "functions")] #[cfg(feature = "functions")]
InvalidFunctionParameterType(usize, Type), InvalidFunctionParameterType(usize, Type),
/// Error returned by `vtab::Values::get` when the filter argument cannot /// Error returned by [`vtab::Values::get`](crate::vtab::Values::get) when the filter argument cannot
/// be converted to the requested type. /// be converted to the requested type.
#[cfg(feature = "vtab")] #[cfg(feature = "vtab")]
InvalidFilterParameterType(usize, Type), InvalidFilterParameterType(usize, Type),
/// An error case available for implementors of custom user functions (e.g., /// An error case available for implementors of custom user functions (e.g.,
/// `create_scalar_function`). /// [`create_scalar_function`](crate::Connection::create_scalar_function)).
#[cfg(feature = "functions")] #[cfg(feature = "functions")]
#[allow(dead_code)] #[allow(dead_code)]
UserFunctionError(Box<dyn error::Error + Send + Sync + 'static>), UserFunctionError(Box<dyn error::Error + Send + Sync + 'static>),
/// Error available for the implementors of the `ToSql` trait. /// Error available for the implementors of the [`ToSql`](crate::types::ToSql) trait.
ToSqlConversionFailure(Box<dyn error::Error + Send + Sync + 'static>), ToSqlConversionFailure(Box<dyn error::Error + Send + Sync + 'static>),
/// Error when the SQL is not a `SELECT`, is not read-only. /// Error when the SQL is not a `SELECT`, is not read-only.
InvalidQuery, InvalidQuery,
/// An error case available for implementors of custom modules (e.g., /// An error case available for implementors of custom modules (e.g.,
/// `create_module`). /// [`create_module`](crate::Connection::create_module)).
#[cfg(feature = "vtab")] #[cfg(feature = "vtab")]
#[allow(dead_code)] #[allow(dead_code)]
ModuleError(String), ModuleError(String),
@ -98,8 +98,8 @@ pub enum Error {
#[cfg(feature = "functions")] #[cfg(feature = "functions")]
UnwindingPanic, UnwindingPanic,
/// An error returned when `Context::get_aux` attempts to retrieve data /// An error returned when [`Context::get_aux`](crate::functions::Context::get_aux) attempts to retrieve data
/// of a different type than what had been stored using `Context::set_aux`. /// of a different type than what had been stored using [`Context::set_aux`](crate::functions::Context::set_aux).
#[cfg(feature = "functions")] #[cfg(feature = "functions")]
GetAuxWrongType, GetAuxWrongType,

View File

@ -126,7 +126,7 @@ impl Context<'_> {
/// ///
/// # Failure /// # Failure
/// ///
/// Will panic if `idx` is greater than or equal to `self.len()`. /// Will panic if `idx` is greater than or equal to [`self.len()`](Context::len).
/// ///
/// Will return Err if the underlying SQLite type cannot be converted to a /// Will return Err if the underlying SQLite type cannot be converted to a
/// `T`. /// `T`.
@ -156,16 +156,16 @@ impl Context<'_> {
/// ///
/// # Failure /// # Failure
/// ///
/// Will panic if `idx` is greater than or equal to `self.len()`. /// Will panic if `idx` is greater than or equal to [`self.len()`](Context::len).
#[inline] #[inline]
pub fn get_raw(&self, idx: usize) -> ValueRef<'_> { pub fn get_raw(&self, idx: usize) -> ValueRef<'_> {
let arg = self.args[idx]; let arg = self.args[idx];
unsafe { ValueRef::from_value(arg) } unsafe { ValueRef::from_value(arg) }
} }
/// Fetch or insert the the auxilliary data associated with a particular /// Fetch or insert the auxilliary data associated with a particular
/// parameter. This is intended to be an easier-to-use way of fetching it /// parameter. This is intended to be an easier-to-use way of fetching it
/// compared to calling `get_aux` and `set_aux` separately. /// compared to calling [`get_aux`](Context::get_aux) and [`set_aux`](Context::set_aux) separately.
/// ///
/// See `https://www.sqlite.org/c3ref/get_auxdata.html` for a discussion of /// See `https://www.sqlite.org/c3ref/get_auxdata.html` for a discussion of
/// this feature, or the unit tests of this module for an example. /// this feature, or the unit tests of this module for an example.
@ -206,7 +206,7 @@ impl Context<'_> {
} }
/// Gets the auxilliary data that was associated with a given parameter via /// Gets the auxilliary data that was associated with a given parameter via
/// `set_aux`. Returns `Ok(None)` if no data has been associated, and /// [`set_aux`](Context::set_aux). Returns `Ok(None)` if no data has been associated, and
/// Ok(Some(v)) if it has. Returns an error if the requested type does not /// Ok(Some(v)) if it has. Returns an error if the requested type does not
/// match. /// match.
pub fn get_aux<T: Send + Sync + 'static>(&self, arg: c_int) -> Result<Option<Arc<T>>> { pub fn get_aux<T: Send + Sync + 'static>(&self, arg: c_int) -> Result<Option<Arc<T>>> {
@ -235,7 +235,7 @@ where
T: ToSql, T: ToSql,
{ {
/// Initializes the aggregation context. Will be called prior to the first /// Initializes the aggregation context. Will be called prior to the first
/// call to `step()` to set up the context for an invocation of the /// call to [`step()`](Aggregate::step) to set up the context for an invocation of the
/// function. (Note: `init()` will not be called if there are no rows.) /// function. (Note: `init()` will not be called if there are no rows.)
fn init(&self) -> A; fn init(&self) -> A;
@ -244,9 +244,9 @@ where
fn step(&self, _: &mut Context<'_>, _: &mut A) -> Result<()>; fn step(&self, _: &mut Context<'_>, _: &mut A) -> Result<()>;
/// Computes and returns the final result. Will be called exactly once for /// Computes and returns the final result. Will be called exactly once for
/// each invocation of the function. If `step()` was called at least /// each invocation of the function. If [`step()`](Aggregate::step) was called at least
/// once, will be given `Some(A)` (the same `A` as was created by /// once, will be given `Some(A)` (the same `A` as was created by
/// `init` and given to `step`); if `step()` was not called (because /// [`init`](Aggregate::init) and given to [`step`](Aggregate::step)); if [`step()`](Aggregate::step) was not called (because
/// the function is running against 0 rows), will be given `None`. /// the function is running against 0 rows), will be given `None`.
fn finalize(&self, _: Option<A>) -> Result<T>; fn finalize(&self, _: Option<A>) -> Result<T>;
} }
@ -309,7 +309,7 @@ impl Connection {
/// given the same input, `deterministic` should be `true`. /// given the same input, `deterministic` should be `true`.
/// ///
/// The function will remain available until the connection is closed or /// The function will remain available until the connection is closed or
/// until it is explicitly removed via `remove_function`. /// until it is explicitly removed via [`remove_function`](Connection::remove_function).
/// ///
/// # Example /// # Example
/// ///
@ -405,7 +405,7 @@ impl Connection {
/// database connection. /// database connection.
/// ///
/// `fn_name` and `n_arg` should match the name and number of arguments /// `fn_name` and `n_arg` should match the name and number of arguments
/// given to `create_scalar_function` or `create_aggregate_function`. /// given to [`create_scalar_function`](Connection::create_scalar_function) or [`create_aggregate_function`](Connection::create_aggregate_function).
/// ///
/// # Failure /// # Failure
/// ///

View File

@ -20,7 +20,7 @@
//! name TEXT NOT NULL, //! name TEXT NOT NULL,
//! data BLOB //! data BLOB
//! )", //! )",
//! params![], //! [],
//! )?; //! )?;
//! let me = Person { //! let me = Person {
//! id: 0, //! id: 0,
@ -33,7 +33,7 @@
//! )?; //! )?;
//! //!
//! let mut stmt = conn.prepare("SELECT id, name, data FROM person")?; //! let mut stmt = conn.prepare("SELECT id, name, data FROM person")?;
//! let person_iter = stmt.query_map(params![], |row| { //! let person_iter = stmt.query_map([], |row| {
//! Ok(Person { //! Ok(Person {
//! id: row.get(0)?, //! id: row.get(0)?,
//! name: row.get(1)?, //! name: row.get(1)?,
@ -455,8 +455,7 @@ impl Connection {
/// ```rust,no_run /// ```rust,no_run
/// # use rusqlite::{Connection, Result}; /// # use rusqlite::{Connection, Result};
/// fn create_tables(conn: &Connection) -> Result<()> { /// fn create_tables(conn: &Connection) -> Result<()> {
/// conn.execute_batch( /// conn.execute_batch("BEGIN;
/// "BEGIN;
/// CREATE TABLE foo(x INTEGER); /// CREATE TABLE foo(x INTEGER);
/// CREATE TABLE bar(y TEXT); /// CREATE TABLE bar(y TEXT);
/// COMMIT;", /// COMMIT;",
@ -859,7 +858,7 @@ impl fmt::Debug for Connection {
/// Batch iterator /// Batch iterator
/// ```rust /// ```rust
/// use rusqlite::{Batch, Connection, Result, NO_PARAMS}; /// use rusqlite::{Batch, Connection, Result};
/// ///
/// fn main() -> Result<()> { /// fn main() -> Result<()> {
/// let conn = Connection::open_in_memory()?; /// let conn = Connection::open_in_memory()?;
@ -869,7 +868,7 @@ impl fmt::Debug for Connection {
/// "; /// ";
/// let mut batch = Batch::new(&conn, sql); /// let mut batch = Batch::new(&conn, sql);
/// while let Some(mut stmt) = batch.next()? { /// while let Some(mut stmt) = batch.next()? {
/// stmt.execute(NO_PARAMS)?; /// stmt.execute([])?;
/// } /// }
/// Ok(()) /// Ok(())
/// } /// }

View File

@ -21,7 +21,7 @@ use sealed::Sealed;
/// ///
/// Many functions in this library let you pass parameters to SQLite. Doing this /// Many functions in this library let you pass parameters to SQLite. Doing this
/// lets you avoid any risk of SQL injection, and is simpler than escaping /// lets you avoid any risk of SQL injection, and is simpler than escaping
/// things manually. Aside from deprecated functions and a few helpers, this is /// things manually. Aside from deprecated functions and a few helpers, this is
/// indicated by the function taking a generic argument that implements `Params` /// indicated by the function taking a generic argument that implements `Params`
/// (this trait). /// (this trait).
/// ///

View File

@ -29,7 +29,7 @@ impl<'stmt> Rows<'stmt> {
/// This interface is not compatible with Rust's `Iterator` trait, because /// This interface is not compatible with Rust's `Iterator` trait, because
/// the lifetime of the returned row is tied to the lifetime of `self`. /// the lifetime of the returned row is tied to the lifetime of `self`.
/// This is a fallible "streaming iterator". For a more natural interface, /// This is a fallible "streaming iterator". For a more natural interface,
/// consider using `query_map` or `query_and_then` instead, which /// consider using [`query_map`](crate::Statement::query_map) or [`query_and_then`](crate::Statement::query_and_then) instead, which
/// return types that implement `Iterator`. /// return types that implement `Iterator`.
#[allow(clippy::should_implement_trait)] // cannot implement Iterator #[allow(clippy::should_implement_trait)] // cannot implement Iterator
#[inline] #[inline]

View File

@ -411,7 +411,7 @@ impl Drop for ChangesetIter<'_> {
} }
/// `feature = "session"` An item passed to a conflict-handler by /// `feature = "session"` An item passed to a conflict-handler by
/// `Connection::apply`, or an item generated by `ChangesetIter::next`. /// [`Connection::apply`](crate::Connection::apply), or an item generated by [`ChangesetIter::next`](ChangesetIter::next).
// TODO enum ? Delete, Insert, Update, ... // TODO enum ? Delete, Insert, Update, ...
pub struct ChangesetItem { pub struct ChangesetItem {
it: *mut ffi::sqlite3_changeset_iter, it: *mut ffi::sqlite3_changeset_iter,

View File

@ -114,7 +114,7 @@ impl Statement<'_> {
/// ///
/// # Note /// # Note
/// ///
/// This function is a convenience wrapper around `execute()` intended for /// This function is a convenience wrapper around [`execute()`](Statement::execute) intended for
/// queries that insert a single item. It is possible to misuse this /// queries that insert a single item. It is possible to misuse this
/// function in a way that it cannot detect, such as by calling it on a /// function in a way that it cannot detect, such as by calling it on a
/// statement which _updates_ a single /// statement which _updates_ a single
@ -136,8 +136,8 @@ impl Statement<'_> {
/// rows. /// rows.
/// ///
/// Due to lifetime restricts, the rows handle returned by `query` does not /// Due to lifetime restricts, the rows handle returned by `query` does not
/// implement the `Iterator` trait. Consider using `query_map` or /// implement the `Iterator` trait. Consider using [`query_map`](Statement::query_map) or
/// `query_and_then` instead, which do. /// [`query_and_then`](Statement::query_and_then) instead, which do.
/// ///
/// ## Example /// ## Example
/// ///
@ -437,7 +437,7 @@ impl Statement<'_> {
/// ignored. /// ignored.
/// ///
/// Returns `Err(QueryReturnedNoRows)` if no results are returned. If the /// Returns `Err(QueryReturnedNoRows)` if no results are returned. If the
/// query truly is optional, you can call `.optional()` on the result of /// query truly is optional, you can call [`.optional()`](crate::OptionalExtension::optional) on the result of
/// this to get a `Result<Option<T>>` (requires that the trait `rusqlite::OptionalExtension` /// this to get a `Result<Option<T>>` (requires that the trait `rusqlite::OptionalExtension`
/// is imported). /// is imported).
/// ///
@ -464,7 +464,7 @@ impl Statement<'_> {
/// ignored. /// ignored.
/// ///
/// Returns `Err(QueryReturnedNoRows)` if no results are returned. If the /// Returns `Err(QueryReturnedNoRows)` if no results are returned. If the
/// query truly is optional, you can call `.optional()` on the result of /// query truly is optional, you can call [`.optional()`](crate::OptionalExtension::optional) on the result of
/// this to get a `Result<Option<T>>` (requires that the trait `rusqlite::OptionalExtension` /// this to get a `Result<Option<T>>` (requires that the trait `rusqlite::OptionalExtension`
/// is imported). /// is imported).
/// ///
@ -493,7 +493,7 @@ impl Statement<'_> {
self.finalize_() self.finalize_()
} }
/// Return the (one-based) index of an SQL parameter given its name. /// Return the (one-based) index of an SQL parameter given its name.
/// ///
/// Note that the initial ":" or "$" or "@" or "?" used to specify the /// Note that the initial ":" or "$" or "@" or "?" used to specify the
/// parameter is included as part of the name. /// parameter is included as part of the name.
@ -563,7 +563,7 @@ impl Statement<'_> {
/// Low level API to directly bind a parameter to a given index. /// Low level API to directly bind a parameter to a given index.
/// ///
/// Note that the index is one-based, that is, the first parameter index is /// Note that the index is one-based, that is, the first parameter index is
/// 1 and not 0. This is consistent with the SQLite API and the values given /// 1 and not 0. This is consistent with the SQLite API and the values given
/// to parameters bound as `?NNN`. /// to parameters bound as `?NNN`.
/// ///

View File

@ -377,8 +377,8 @@ impl Connection {
/// Begin a new transaction with the default behavior (DEFERRED). /// Begin a new transaction with the default behavior (DEFERRED).
/// ///
/// The transaction defaults to rolling back when it is dropped. If you /// The transaction defaults to rolling back when it is dropped. If you
/// want the transaction to commit, you must call `commit` or /// want the transaction to commit, you must call [`commit`](Transaction::commit) or
/// `set_drop_behavior(DropBehavior::Commit)`. /// [`set_drop_behavior(DropBehavior::Commit)`](Transaction::set_drop_behavior).
/// ///
/// ## Example /// ## Example
/// ///
@ -406,7 +406,7 @@ impl Connection {
/// Begin a new transaction with a specified behavior. /// Begin a new transaction with a specified behavior.
/// ///
/// See `transaction`. /// See [`transaction`](Connection::transaction).
/// ///
/// # Failure /// # Failure
/// ///
@ -457,8 +457,8 @@ impl Connection {
/// Begin a new savepoint with the default behavior (DEFERRED). /// Begin a new savepoint with the default behavior (DEFERRED).
/// ///
/// The savepoint defaults to rolling back when it is dropped. If you want /// The savepoint defaults to rolling back when it is dropped. If you want
/// the savepoint to commit, you must call `commit` or /// the savepoint to commit, you must call [`commit`](Savepoint::commit) or
/// `set_drop_behavior(DropBehavior::Commit)`. /// [`set_drop_behavior(DropBehavior::Commit)`](Savepoint::set_drop_behavior).
/// ///
/// ## Example /// ## Example
/// ///
@ -486,7 +486,7 @@ impl Connection {
/// Begin a new savepoint with a specified name. /// Begin a new savepoint with a specified name.
/// ///
/// See `savepoint`. /// See [`savepoint`](Connection::savepoint).
/// ///
/// # Failure /// # Failure
/// ///

View File

@ -3,7 +3,7 @@ use std::convert::TryInto;
use std::error::Error; use std::error::Error;
use std::fmt; use std::fmt;
/// Enum listing possible errors from `FromSql` trait. /// Enum listing possible errors from [`FromSql`] trait.
#[derive(Debug)] #[derive(Debug)]
#[non_exhaustive] #[non_exhaustive]
pub enum FromSqlError { pub enum FromSqlError {
@ -26,7 +26,7 @@ pub enum FromSqlError {
#[cfg(feature = "uuid")] #[cfg(feature = "uuid")]
InvalidUuidSize(usize), InvalidUuidSize(usize),
/// An error case available for implementors of the `FromSql` trait. /// An error case available for implementors of the [`FromSql`] trait.
Other(Box<dyn Error + Send + Sync + 'static>), Other(Box<dyn Error + Send + Sync + 'static>),
} }
@ -72,20 +72,10 @@ impl Error for FromSqlError {
} }
} }
/// Result type for implementors of the `FromSql` trait. /// Result type for implementors of the [`FromSql`] trait.
pub type FromSqlResult<T> = Result<T, FromSqlError>; pub type FromSqlResult<T> = Result<T, FromSqlError>;
/// A trait for types that can be created from a SQLite value. /// A trait for types that can be created from a SQLite value.
///
/// Note that `FromSql` and `ToSql` are defined for most integral types, but
/// not `u64` or `usize`. This is intentional; SQLite returns integers as
/// signed 64-bit values, which cannot fully represent the range of these
/// types. Rusqlite would have to
/// decide how to handle negative values: return an error or reinterpret as a
/// very large postive numbers, neither of which
/// is guaranteed to be correct for everyone. Callers can work around this by
/// fetching values as i64 and then doing the interpretation themselves or by
/// defining a newtype and implementing `FromSql`/`ToSql` for it.
pub trait FromSql: Sized { pub trait FromSql: Sized {
/// Converts SQLite value into Rust value. /// Converts SQLite value into Rust value.
fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self>; fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self>;

View File

@ -1,7 +1,7 @@
//! Traits dealing with SQLite data types. //! Traits dealing with SQLite data types.
//! //!
//! SQLite uses a [dynamic type system](https://www.sqlite.org/datatype3.html). Implementations of //! SQLite uses a [dynamic type system](https://www.sqlite.org/datatype3.html). Implementations of
//! the `ToSql` and `FromSql` traits are provided for the basic types that //! the [`ToSql`] and [`FromSql`] traits are provided for the basic types that
//! SQLite provides methods for: //! SQLite provides methods for:
//! //!
//! * Strings (`String` and `&str`) //! * Strings (`String` and `&str`)
@ -11,17 +11,17 @@
//! The number situation is a little complicated due to the fact that all //! The number situation is a little complicated due to the fact that all
//! numbers in SQLite are stored as `INTEGER` (`i64`) or `REAL` (`f64`). //! numbers in SQLite are stored as `INTEGER` (`i64`) or `REAL` (`f64`).
//! //!
//! `ToSql` and `FromSql` are implemented for all primitive number types. //! [`ToSql`] and [`FromSql`] are implemented for all primitive number types.
//! `FromSql` has different behaviour depending on the SQL and Rust types, and //! [`FromSql`] has different behaviour depending on the SQL and Rust types, and
//! the value. //! the value.
//! //!
//! * `INTEGER` to integer: returns an `Error::IntegralValueOutOfRange` error if //! * `INTEGER` to integer: returns an [`Error::IntegralValueOutOfRange`](crate::Error::IntegralValueOutOfRange) error if
//! the value does not fit in the Rust type. //! the value does not fit in the Rust type.
//! * `REAL` to integer: always returns an `Error::InvalidColumnType` error. //! * `REAL` to integer: always returns an [`Error::InvalidColumnType`](crate::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.
//! //!
//! `ToSql` always succeeds except when storing a `u64` or `usize` value that //! [`ToSql`] always succeeds except when storing a `u64` or `usize` value that
//! cannot fit in an `INTEGER` (`i64`). Also note that SQLite ignores column //! cannot fit in an `INTEGER` (`i64`). Also note that SQLite ignores column
//! types, so if you store an `i64` in a column with type `REAL` it will be //! types, so if you store an `i64` in a column with type `REAL` it will be
//! stored as an `INTEGER`, not a `REAL`. //! stored as an `INTEGER`, not a `REAL`.
@ -61,8 +61,8 @@ impl ToSql for DateTimeSql {
"## "##
)] )]
//! `ToSql` and `FromSql` are also implemented for `Option<T>` where `T` //! [`ToSql`] and [`FromSql`] are also implemented for `Option<T>` where `T`
//! implements `ToSql` or `FromSql` for the cases where you want to know if a //! implements [`ToSql`] or [`FromSql`] for the cases where you want to know if a
//! value was NULL (which gets translated to `None`). //! value was NULL (which gets translated to `None`).
pub use self::from_sql::{FromSql, FromSqlError, FromSqlResult}; pub use self::from_sql::{FromSql, FromSqlError, FromSqlResult};

View File

@ -1,4 +1,4 @@
//! `ToSql` and `FromSql` implementation for JSON `Value`. //! [`ToSql`] and [`FromSql`] implementation for JSON `Value`.
use serde_json::Value; use serde_json::Value;

View File

@ -1,4 +1,4 @@
//! `ToSql` and `FromSql` implementation for [`time::OffsetDateTime`]. //! [`ToSql`] and [`FromSql`] implementation for [`time::OffsetDateTime`].
use crate::types::{FromSql, FromSqlError, FromSqlResult, ToSql, ToSqlOutput, ValueRef}; use crate::types::{FromSql, FromSqlError, FromSqlResult, ToSql, ToSqlOutput, ValueRef};
use crate::Result; use crate::Result;
use time::{OffsetDateTime, PrimitiveDateTime, UtcOffset}; use time::{OffsetDateTime, PrimitiveDateTime, UtcOffset};

View File

@ -6,7 +6,7 @@ use std::borrow::Cow;
use std::convert::TryFrom; use std::convert::TryFrom;
/// `ToSqlOutput` represents the possible output types for implementers of the /// `ToSqlOutput` represents the possible output types for implementers of the
/// `ToSql` trait. /// [`ToSql`] trait.
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq)]
#[non_exhaustive] #[non_exhaustive]
pub enum ToSqlOutput<'a> { pub enum ToSqlOutput<'a> {
@ -91,7 +91,7 @@ impl ToSql for ToSqlOutput<'_> {
} }
/// A trait for types that can be converted into SQLite values. Returns /// A trait for types that can be converted into SQLite values. Returns
/// `Error::ToSqlConversionFailure` if the conversion fails. /// [`Error::ToSqlConversionFailure`] if the conversion fails.
pub trait ToSql { pub trait ToSql {
/// Converts Rust value to SQLite value /// Converts Rust value to SQLite value
fn to_sql(&self) -> Result<ToSqlOutput<'_>>; fn to_sql(&self) -> Result<ToSqlOutput<'_>>;

View File

@ -1,4 +1,4 @@
//! `ToSql` and `FromSql` implementation for [`url::Url`]. //! [`ToSql`] and [`FromSql`] implementation for [`url::Url`].
use crate::types::{FromSql, FromSqlError, FromSqlResult, ToSql, ToSqlOutput, ValueRef}; use crate::types::{FromSql, FromSqlError, FromSqlResult, ToSql, ToSqlOutput, ValueRef};
use crate::Result; use crate::Result;
use url::Url; use url::Url;

View File

@ -3,7 +3,7 @@ use super::{Null, Type};
/// Owning [dynamic type value](http://sqlite.org/datatype3.html). Value's type is typically /// Owning [dynamic type value](http://sqlite.org/datatype3.html). Value's type is typically
/// dictated by SQLite (not by the caller). /// dictated by SQLite (not by the caller).
/// ///
/// See [`ValueRef`](enum.ValueRef.html) for a non-owning dynamic type value. /// See [`ValueRef`](crate::types::ValueRef) for a non-owning dynamic type value.
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub enum Value { pub enum Value {
/// The value is a `NULL` value. /// The value is a `NULL` value.

View File

@ -4,7 +4,7 @@ use crate::types::{FromSqlError, FromSqlResult};
/// A non-owning [dynamic type value](http://sqlite.org/datatype3.html). Typically the /// A non-owning [dynamic type value](http://sqlite.org/datatype3.html). Typically the
/// memory backing this value is owned by SQLite. /// memory backing this value is owned by SQLite.
/// ///
/// See [`Value`](enum.Value.html) for an owning dynamic type value. /// See [`Value`](Value) for an owning dynamic type value.
#[derive(Copy, Clone, Debug, PartialEq)] #[derive(Copy, Clone, Debug, PartialEq)]
pub enum ValueRef<'a> { pub enum ValueRef<'a> {
/// The value is a `NULL` value. /// The value is a `NULL` value.
@ -35,7 +35,7 @@ impl ValueRef<'_> {
impl<'a> ValueRef<'a> { impl<'a> ValueRef<'a> {
/// If `self` is case `Integer`, returns the integral value. Otherwise, /// If `self` is case `Integer`, returns the integral value. Otherwise,
/// returns `Err(Error::InvalidColumnType)`. /// returns [`Err(Error::InvalidColumnType)`](crate::Error::InvalidColumnType).
#[inline] #[inline]
pub fn as_i64(&self) -> FromSqlResult<i64> { pub fn as_i64(&self) -> FromSqlResult<i64> {
match *self { match *self {
@ -45,7 +45,7 @@ impl<'a> ValueRef<'a> {
} }
/// If `self` is case `Real`, returns the floating point value. Otherwise, /// If `self` is case `Real`, returns the floating point value. Otherwise,
/// returns `Err(Error::InvalidColumnType)`. /// returns [`Err(Error::InvalidColumnType)`](crate::Error::InvalidColumnType).
#[inline] #[inline]
pub fn as_f64(&self) -> FromSqlResult<f64> { pub fn as_f64(&self) -> FromSqlResult<f64> {
match *self { match *self {
@ -55,7 +55,7 @@ impl<'a> ValueRef<'a> {
} }
/// If `self` is case `Text`, returns the string value. Otherwise, returns /// If `self` is case `Text`, returns the string value. Otherwise, returns
/// `Err(Error::InvalidColumnType)`. /// [`Err(Error::InvalidColumnType)`](crate::Error::InvalidColumnType).
#[inline] #[inline]
pub fn as_str(&self) -> FromSqlResult<&'a str> { pub fn as_str(&self) -> FromSqlResult<&'a str> {
match *self { match *self {
@ -67,7 +67,7 @@ impl<'a> ValueRef<'a> {
} }
/// If `self` is case `Blob`, returns the byte slice. Otherwise, returns /// If `self` is case `Blob`, returns the byte slice. Otherwise, returns
/// `Err(Error::InvalidColumnType)`. /// [`Err(Error::InvalidColumnType)`](crate::Error::InvalidColumnType).
#[inline] #[inline]
pub fn as_blob(&self) -> FromSqlResult<&'a [u8]> { pub fn as_blob(&self) -> FromSqlResult<&'a [u8]> {
match *self { match *self {

View File

@ -1,10 +1,10 @@
//! `feature = "vtab"` Create virtual tables. //! `feature = "vtab"` Create virtual tables.
//! //!
//! Follow these steps to create your own virtual table: //! Follow these steps to create your own virtual table:
//! 1. Write implemenation of `VTab` and `VTabCursor` traits. //! 1. Write implemenation of [`VTab`] and [`VTabCursor`] traits.
//! 2. Create an instance of the `Module` structure specialized for `VTab` impl. //! 2. Create an instance of the [`Module`] structure specialized for [`VTab`] impl.
//! from step 1. //! from step 1.
//! 3. Register your `Module` structure using `Connection.create_module`. //! 3. Register your [`Module`] structure using [`Connection::create_module`].
//! 4. Run a `CREATE VIRTUAL TABLE` command that specifies the new module in the //! 4. Run a `CREATE VIRTUAL TABLE` command that specifies the new module in the
//! `USING` clause. //! `USING` clause.
//! //!
@ -205,7 +205,7 @@ impl VTabConnection {
/// ///
/// (See [SQLite doc](https://sqlite.org/c3ref/vtab.html)) /// (See [SQLite doc](https://sqlite.org/c3ref/vtab.html))
pub unsafe trait VTab<'vtab>: Sized { pub unsafe trait VTab<'vtab>: Sized {
/// Client data passed to `Connection::create_module`. /// Client data passed to [`Connection::create_module`].
type Aux; type Aux;
/// Specific cursor implementation /// Specific cursor implementation
type Cursor: VTabCursor; type Cursor: VTabCursor;
@ -237,7 +237,7 @@ pub trait CreateVTab<'vtab>: VTab<'vtab> {
/// database connection that is executing the CREATE VIRTUAL TABLE /// database connection that is executing the CREATE VIRTUAL TABLE
/// statement. /// statement.
/// ///
/// Call `connect` by default. /// Call [`connect`](VTab::connect) by default.
/// (See [SQLite doc](https://sqlite.org/vtab.html#the_xcreate_method)) /// (See [SQLite doc](https://sqlite.org/vtab.html#the_xcreate_method))
fn create( fn create(
db: &mut VTabConnection, db: &mut VTabConnection,
@ -248,7 +248,7 @@ pub trait CreateVTab<'vtab>: VTab<'vtab> {
} }
/// Destroy the underlying table implementation. This method undoes the work /// Destroy the underlying table implementation. This method undoes the work
/// of `create`. /// of [`create`](CreateVTab::create).
/// ///
/// Do nothing by default. /// Do nothing by default.
/// (See [SQLite doc](https://sqlite.org/vtab.html#the_xdestroy_method)) /// (See [SQLite doc](https://sqlite.org/vtab.html#the_xdestroy_method))
@ -302,7 +302,7 @@ impl From<u8> for IndexConstraintOp {
} }
/// `feature = "vtab"` Pass information into and receive the reply from the /// `feature = "vtab"` Pass information into and receive the reply from the
/// `VTab.best_index` method. /// [`VTab::best_index`] method.
/// ///
/// (See [SQLite doc](http://sqlite.org/c3ref/index_info.html)) /// (See [SQLite doc](http://sqlite.org/c3ref/index_info.html))
pub struct IndexInfo(*mut ffi::sqlite3_index_info); pub struct IndexInfo(*mut ffi::sqlite3_index_info);
@ -334,7 +334,7 @@ impl IndexInfo {
unsafe { (*self.0).nOrderBy as usize } unsafe { (*self.0).nOrderBy as usize }
} }
/// Information about what parameters to pass to `VTabCursor.filter`. /// Information about what parameters to pass to [`VTabCursor::filter`].
#[inline] #[inline]
pub fn constraint_usage(&mut self, constraint_idx: usize) -> IndexConstraintUsage<'_> { pub fn constraint_usage(&mut self, constraint_idx: usize) -> IndexConstraintUsage<'_> {
let constraint_usages = unsafe { let constraint_usages = unsafe {
@ -425,11 +425,11 @@ impl IndexConstraint<'_> {
} }
/// `feature = "vtab"` Information about what parameters to pass to /// `feature = "vtab"` Information about what parameters to pass to
/// `VTabCursor.filter`. /// [`VTabCursor::filter`].
pub struct IndexConstraintUsage<'a>(&'a mut ffi::sqlite3_index_constraint_usage); pub struct IndexConstraintUsage<'a>(&'a mut ffi::sqlite3_index_constraint_usage);
impl IndexConstraintUsage<'_> { impl IndexConstraintUsage<'_> {
/// if `argv_index` > 0, constraint is part of argv to `VTabCursor.filter` /// if `argv_index` > 0, constraint is part of argv to [`VTabCursor::filter`]
#[inline] #[inline]
pub fn set_argv_index(&mut self, argv_index: c_int) { pub fn set_argv_index(&mut self, argv_index: c_int) {
self.0.argvIndex = argv_index; self.0.argvIndex = argv_index;
@ -495,7 +495,7 @@ pub unsafe trait VTabCursor: Sized {
/// Begin a search of a virtual table. /// Begin a search of a virtual table.
/// (See [SQLite doc](https://sqlite.org/vtab.html#the_xfilter_method)) /// (See [SQLite doc](https://sqlite.org/vtab.html#the_xfilter_method))
fn filter(&mut self, idx_num: c_int, idx_str: Option<&str>, args: &Values<'_>) -> Result<()>; fn filter(&mut self, idx_num: c_int, idx_str: Option<&str>, args: &Values<'_>) -> Result<()>;
/// Advance cursor to the next row of a result set initiated by `filter`. /// Advance cursor to the next row of a result set initiated by [`filter`](VTabCursor::filter).
/// (See [SQLite doc](https://sqlite.org/vtab.html#the_xnext_method)) /// (See [SQLite doc](https://sqlite.org/vtab.html#the_xnext_method))
fn next(&mut self) -> Result<()>; fn next(&mut self) -> Result<()>;
/// Must return `false` if the cursor currently points to a valid row of /// Must return `false` if the cursor currently points to a valid row of
@ -512,7 +512,7 @@ pub unsafe trait VTabCursor: Sized {
fn rowid(&self) -> Result<i64>; fn rowid(&self) -> Result<i64>;
} }
/// `feature = "vtab"` Context is used by `VTabCursor.column` to specify the /// `feature = "vtab"` Context is used by [`VTabCursor::column`] to specify the
/// cell value. /// cell value.
pub struct Context(*mut ffi::sqlite3_context); pub struct Context(*mut ffi::sqlite3_context);
@ -528,8 +528,8 @@ impl Context {
// TODO sqlite3_vtab_nochange (http://sqlite.org/c3ref/vtab_nochange.html) // TODO sqlite3_vtab_nochange (http://sqlite.org/c3ref/vtab_nochange.html)
} }
/// `feature = "vtab"` Wrapper to `VTabCursor.filter` arguments, the values /// `feature = "vtab"` Wrapper to [`VTabCursor::filter`] arguments, the values
/// requested by `VTab.best_index`. /// requested by [`VTab::best_index`].
pub struct Values<'a> { pub struct Values<'a> {
args: &'a [*mut ffi::sqlite3_value], args: &'a [*mut ffi::sqlite3_value],
} }
@ -606,7 +606,7 @@ impl<'a> IntoIterator for &'a Values<'a> {
} }
} }
/// `Values` iterator. /// [`Values`] iterator.
pub struct ValueIter<'a> { pub struct ValueIter<'a> {
iter: slice::Iter<'a, *mut ffi::sqlite3_value>, iter: slice::Iter<'a, *mut ffi::sqlite3_value>,
} }