toasty_core/
lib.rs

1//! Core types and abstractions for the Toasty ORM.
2//!
3//! This crate provides the shared foundation used by all Toasty components:
4//!
5//! - [`Schema`] -- the combined app-level, database-level, and mapping schema
6//! - [`stmt`] -- the statement AST used to represent queries and mutations
7//! - [`driver`] -- the trait interface that database drivers implement
8//! - [`Error`] / [`Result`] -- unified error handling
9//!
10//! Most users interact with the higher-level `toasty` crate. This crate is
11//! relevant when writing database drivers or working with schema internals.
12//!
13//! # Examples
14//!
15//! ```ignore
16//! use toasty_core::{Schema, Error, Result};
17//!
18//! fn check_schema(schema: &Schema) -> Result<()> {
19//!     println!("models: {}", schema.app.models.len());
20//!     Ok(())
21//! }
22//! ```
23
24#![warn(missing_docs)]
25
26#[macro_use]
27mod macros;
28
29/// Database driver traits and capability descriptions.
30pub mod driver;
31pub use driver::Connection;
32
33mod error;
34/// The error type returned by Toasty operations.
35pub use error::Error;
36
37/// Schema definitions spanning the app layer, database layer, and the mapping
38/// between them.
39pub mod schema;
40pub use schema::Schema;
41
42/// Statement AST types for representing queries, inserts, updates, and deletes.
43pub mod stmt;
44
45/// A `Result` type alias that uses Toasty's [`Error`] type.
46///
47/// This is the standard return type for fallible operations throughout
48/// `toasty-core`.
49///
50/// # Examples
51///
52/// ```ignore
53/// use toasty_core::Result;
54///
55/// fn validate_name(name: &str) -> Result<()> {
56///     if name.is_empty() {
57///         return Err(toasty_core::Error::invalid_schema("name must not be empty"));
58///     }
59///     Ok(())
60/// }
61/// ```
62pub type Result<T, E = Error> = core::result::Result<T, E>;