Crate exemplar

source ·
Expand description

Exemplar is a boilerplate eliminator for rusqlite.

Getting Started

A taste of what you can do:

#[derive(Model)]
#[table("users")]
#[check("schema.sql")]
struct User {
   username: String,
   #[bind(bind_path)]
   #[extr(extr_path)]
   home_dir: PathBuf,
   #[column("pwd")]
   password: Vec<u8>,
}

Exemplar is based around the Model trait, which has its own derive macro.

  • See the aformentioned macro’s documentation to get started.
  • For handling enums in models, check out the sql_enum macro.
  • For working with “anonymous” record types, look at the record macro.

Cargo Features

  • (Optional) r2d2 - enable integration with r2d2/r2d2_sqlite’s pooled connection type.

Macros

  • Generate an “anonymous” record struct that implements from_row.
  • Generate an SQL-compatible field-less enum.

Structs

Enums

Traits

  • Trait for abstracting over possible connection types.
  • An interface for types that model database tables.

Type Aliases

  • Type alias for the outcome of converting a value to an SQL-friendly representation.
  • Type alias for the outcome of extracting a value from a Row.
  • Type alias for a boxed slice of named query parameters.

Derive Macros