Document which features are required, and add vtab usage examples (#669)

This commit is contained in:
Thom Chiovoloni
2020-04-05 22:15:27 -07:00
committed by GitHub
parent 6edf72857e
commit 6617db59fb
16 changed files with 164 additions and 97 deletions

View File

@@ -1,4 +1,4 @@
//! [Session Extension](https://sqlite.org/sessionintro.html)
//! `feature = "session"` [Session Extension](https://sqlite.org/sessionintro.html)
#![allow(non_camel_case_types)]
use std::ffi::CStr;
@@ -20,7 +20,7 @@ use crate::{errmsg_to_string, str_to_cstring, Connection, DatabaseName, Result};
// https://sqlite.org/session.html
/// An instance of this object is a session that can be used to record changes
/// `feature = "session"` An instance of this object is a session that can be used to record changes
/// to a database.
pub struct Session<'conn> {
phantom: PhantomData<&'conn ()>,
@@ -211,7 +211,7 @@ impl Drop for Session<'_> {
}
}
/// Invert a changeset
/// `feature = "session"` Invert a changeset
pub fn invert_strm(input: &mut dyn Read, output: &mut dyn Write) -> Result<()> {
let input_ref = &input;
let output_ref = &output;
@@ -226,7 +226,7 @@ pub fn invert_strm(input: &mut dyn Read, output: &mut dyn Write) -> Result<()> {
Ok(())
}
/// Combine two changesets
/// `feature = "session"` Combine two changesets
pub fn concat_strm(
input_a: &mut dyn Read,
input_b: &mut dyn Read,
@@ -248,7 +248,7 @@ pub fn concat_strm(
Ok(())
}
/// Changeset or Patchset
/// `feature = "session"` Changeset or Patchset
pub struct Changeset {
cs: *mut c_void,
n: c_int,
@@ -296,7 +296,8 @@ impl Drop for Changeset {
}
}
/// Cursor for iterating over the elements of a changeset or patchset.
/// `feature = "session"` Cursor for iterating over the elements of a changeset
/// or patchset.
pub struct ChangesetIter<'changeset> {
phantom: PhantomData<&'changeset ()>,
it: *mut ffi::sqlite3_changeset_iter,
@@ -347,6 +348,7 @@ impl FallibleStreamingIterator for ChangesetIter<'_> {
}
}
/// `feature = "session"`
pub struct Operation<'item> {
table_name: &'item str,
number_of_columns: i32,
@@ -380,7 +382,7 @@ impl Drop for ChangesetIter<'_> {
}
}
/// An item passed to a conflict-handler by `Connection::apply`,
/// `feature = "session"` An item passed to a conflict-handler by `Connection::apply`,
/// or an item generated by `ChangesetIter::next`.
// TODO enum ? Delete, Insert, Update, ...
pub struct ChangesetItem {
@@ -493,7 +495,7 @@ impl ChangesetItem {
}
}
/// Used to combine two or more changesets or
/// `feature = "session"` Used to combine two or more changesets or
/// patchsets
pub struct Changegroup {
cg: *mut ffi::sqlite3_changegroup,
@@ -558,7 +560,7 @@ impl Drop for Changegroup {
}
impl Connection {
/// Apply a changeset to a database
/// `feature = "session"` Apply a changeset to a database
pub fn apply<F, C>(&self, cs: &Changeset, filter: Option<F>, conflict: C) -> Result<()>
where
F: Fn(&str) -> bool + Send + RefUnwindSafe + 'static,
@@ -592,7 +594,7 @@ impl Connection {
Ok(())
}
/// Apply a changeset to a database
/// `feature = "session"` Apply a changeset to a database
pub fn apply_strm<F, C>(
&self,
input: &mut dyn Read,
@@ -633,7 +635,7 @@ impl Connection {
}
}
/// Constants passed to the conflict handler
/// `feature = "session"` Constants passed to the conflict handler
#[repr(i32)]
#[derive(Debug, PartialEq)]
pub enum ConflictType {
@@ -657,7 +659,7 @@ impl From<i32> for ConflictType {
}
}
/// Constants returned by the conflict handler
/// `feature = "session"` Constants returned by the conflict handler
#[repr(i32)]
#[derive(Debug, PartialEq)]
pub enum ConflictAction {