Refine documentation

This commit is contained in:
Joscha 2022-12-15 14:29:38 +01:00
parent e7c555aa2d
commit 4a8978bbb3
2 changed files with 19 additions and 3 deletions

View file

@ -1,5 +1,5 @@
//! A simple, single-threaded vault. //! A simple, single-threaded vault.
//! //!
//! This vault may be useful if you want to re-use existing [`Action`]s and //! This vault may be useful if you want to re-use existing [`Action`]s and
//! [`Migration`]s but don't need the additional guarantees and overhead of the //! [`Migration`]s but don't need the additional guarantees and overhead of the
//! other vaults. //! other vaults.
@ -9,11 +9,21 @@ use rusqlite::Connection;
use crate::{Action, Migration}; use crate::{Action, Migration};
/// A simple, single-threaded vault. /// A simple, single-threaded vault.
///
/// This vault may be useful if you want to re-use existing [`Action`]s and
/// [`Migration`]s but don't need the additional guarantees and overhead of the
/// other vaults.
pub struct SimpleVault(Connection); pub struct SimpleVault(Connection);
impl SimpleVault { impl SimpleVault {
/// Create a new vault from an existing [`Connection`], applying the /// Create a new vault from an existing [`Connection`], applying the
/// migrations in the process. /// migrations in the process.
///
/// It is recommended to set a few pragmas before calling this function, for
/// example:
/// - `journal_mode` to `"wal"`
/// - `foreign_keys` to `true`
/// - `trusted_schema` to `false`
pub fn new(conn: Connection, migrations: &[Migration]) -> rusqlite::Result<Self> { pub fn new(conn: Connection, migrations: &[Migration]) -> rusqlite::Result<Self> {
Self::new_and_prepare(conn, migrations, |_| Ok(())) Self::new_and_prepare(conn, migrations, |_| Ok(()))
} }
@ -23,6 +33,12 @@ impl SimpleVault {
/// ///
/// The `prepare` parameter allows access to the database after all /// The `prepare` parameter allows access to the database after all
/// migrations have occurred. This parameter could be replaced by executing /// migrations have occurred. This parameter could be replaced by executing
///
/// It is recommended to set a few pragmas before calling this function, for
/// example:
/// - `journal_mode` to `"wal"`
/// - `foreign_keys` to `true`
/// - `trusted_schema` to `false`
/// an [`Action`] performing the same operations. /// an [`Action`] performing the same operations.
pub fn new_and_prepare( pub fn new_and_prepare(
mut conn: Connection, mut conn: Connection,

View file

@ -1,4 +1,4 @@
//! A vault for use with `tokio`. //! A vault for use with [`tokio`].
use std::{any::Any, result, thread}; use std::{any::Any, result, thread};
@ -64,7 +64,7 @@ fn run(mut conn: Connection, mut rx: mpsc::UnboundedReceiver<Command>) {
} }
} }
/// A vault for use with `tokio`. /// A vault for use with [`tokio`].
#[derive(Clone)] #[derive(Clone)]
pub struct TokioVault { pub struct TokioVault {
tx: mpsc::UnboundedSender<Command>, tx: mpsc::UnboundedSender<Command>,