memo: add more documentation to the database module

This commit is contained in:
Ryan Leckey
2020-03-17 16:33:39 -07:00
parent 4fc5e65f5d
commit 100602187f

View File

@@ -9,7 +9,7 @@ use crate::types::TypeInfo;
/// A database driver.
///
/// This trait encapsulates a complete driver implementation to a specific
/// database (e.g., MySQL, Postgres).
/// database (e.g., **MySQL**, **Postgres**).
pub trait Database
where
Self: Sized + Send + 'static,
@@ -29,21 +29,54 @@ where
/// The Rust type of table identifiers for this database.
type TableId: Display + Clone;
type RawBuffer;
/// The Rust type used as the buffer when encoding arguments.
///
/// For example, **Postgres** and **MySQL** use `Vec<u8>`; however, **SQLite** uses `Vec<SqliteArgumentValue>`.
type RawBuffer: Default;
}
/// Associate [`Database`] with a `RawValue` of a generic lifetime.
///
/// ---
///
/// The upcoming Rust feature, [Generic Associated Types], should obviate
/// the need for this trait.
///
/// [Generic Associated Types]: https://www.google.com/search?q=generic+associated+types+rust&oq=generic+associated+types+rust&aqs=chrome..69i57j0l5.3327j0j7&sourceid=chrome&ie=UTF-8
pub trait HasRawValue<'c> {
/// The Rust type used to hold a not-yet-decoded value that has just been
/// received from the database.
///
/// For example, **Postgres** and **MySQL** use `&'c [u8]`; however, **SQLite** uses `SqliteValue<'c>`.
type RawValue;
}
/// Associate [`Database`] with a [`Cursor`] of a generic lifetime.
///
/// ---
///
/// The upcoming Rust feature, [Generic Associated Types], should obviate
/// the need for this trait.
///
/// [Generic Associated Types]: https://www.google.com/search?q=generic+associated+types+rust&oq=generic+associated+types+rust&aqs=chrome..69i57j0l5.3327j0j7&sourceid=chrome&ie=UTF-8
pub trait HasCursor<'c, 'q> {
type Database: Database;
/// The concrete `Cursor` implementation for this database.
type Cursor: Cursor<'c, 'q, Database = Self::Database>;
}
/// Associate [`Database`] with a [`Row`] of a generic lifetime.
///
/// ---
///
/// The upcoming Rust feature, [Generic Associated Types], should obviate
/// the need for this trait.
///
/// [Generic Associated Types]: https://www.google.com/search?q=generic+associated+types+rust&oq=generic+associated+types+rust&aqs=chrome..69i57j0l5.3327j0j7&sourceid=chrome&ie=UTF-8
pub trait HasRow<'c> {
type Database: Database;
/// The concrete `Row` implementation for this database.
type Row: Row<'c, Database = Self::Database>;
}