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

  • (Default) sql_enum - enables the sql_enum macro. Depends on num_enum.

Macros

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

Structs

Enums

Traits

  • 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