Facade crate re-exporting core traits and macros for the storeit-rs library.
This crate provides the main public API. It re-exports all necessary traits and procedural macros so that you only need to add this single crate as a dependency in your application.
Example: Deriving Entity
The #[derive(Entity)] macro generates compile-time metadata about your entity,
including a default RowAdapter implementation.
// This is a non-runnable snippet to avoid pulling backend-specific adapter impls
// into doctest scope. See the runnable examples under `storeit/examples/`.
use storeit::{Entity, Fetchable}; // `Fetchable` must be in scope to access associated constants.
// The macro automatically deduces the table name (`users`) by pluralizing
// the snake_case version of the struct name.
#[derive(Entity, Clone, Debug)]
pub struct User {
// Mark the ID field. The key type (`i64`) and column name ("id") are deduced.
#[fetch(id)]
pub id: Option<i64>,
// You can override column names.
#[fetch(column = "email_address")]
pub email: String,
}
// The `Entity` derive generates metadata constants via the `Fetchable` trait:
assert_eq!(User::TABLE, "users");
assert_eq!(User::SELECT_COLUMNS, &["id", "email_address"]);
// It also generates a `RowAdapter` struct named `UserRowAdapter`.
// This line is a compile-time check that the struct was created.
let _adapter = UserRowAdapter;
Example: Generating a Repository
A runnable example showcasing the #[repository] macro can be found in the
/examples directory of the workspace. It is more comprehensive than a doctest
can be, as it involves multiple crates and backend-specific features.