toasty 0.7.0

An async ORM for Rust supporting SQL and NoSQL databases
Documentation
//! Internal types referenced by code generated by `#[derive(Model)]` and the
//! `create!` / `update!` / `query!` macros. Not part of the public API; the
//! contents may change between releases.

#![doc(hidden)]

pub mod auto;
pub mod newtype;
pub mod storage;
pub mod version;

pub use crate::schema::inventory;
pub use crate::{
    Db, Error, Executor, Result, Statement,
    schema::create_meta::{assert_create_fields, const_contains},
    schema::{
        Auto, CreateField, CreateMeta, CreateScope, Deferred, Direct, DiscoverItem, Embed, Field,
        Load, Model, Register, RelationManyField, RelationOneField, Scope, ValidateCreate, Via,
        generate_unique_id,
    },
    stmt::CreateMany,
    stmt::{self, Assign, IntoExpr, IntoInsert, IntoStatement, List, Path},
    update_target::UpdateTarget,
};
#[cfg(feature = "serde")]
pub use serde_json;
pub use std::{convert::Into, default::Default, option::Option};

pub use self::version::Version;
pub use toasty_core as core;

/// The expression-level type that a create/update setter accepts for a field
/// of type `F`. This is just [`Field::ExprTarget`], but naming it keeps the
/// long `<F as Field>::ExprTarget` projection out of generated setter
/// signatures (and out of the compiler errors they produce).
pub type FieldExprTarget<F> = <F as Field>::ExprTarget;

/// Infer the [`Scope`] type from a scope expression and return its fields
/// path.
///
/// The `create!` macro uses this in the scoped form (`in expr { ... }`) to
/// obtain the field struct for nested builders. Because the macro has no
/// type information, it cannot call `S::new_path_root()` directly — this function
/// lets Rust infer `S` from the scope argument.
pub fn scope_fields<S: CreateScope>(_scope: &S) -> S::Path<S::Item> {
    S::new_path_root()
}

/// Create a record inside a scoped create target.
pub fn create_in_scope<S: CreateScope>(scope: S) -> S::Create {
    S::create_in_scope(scope)
}

/// Convert a value into an untyped [`core::stmt::Expr`] via the typed
/// [`IntoExpr<T>`] trait.
///
/// Generated code (`#[derive(Model)]`, `#[derive(Embed)]`) splices this in
/// instead of inlining the `let expr: Expr<T> = value.into_expr(); expr.into()`
/// pattern at every field site. The explicit `T` type parameter
/// disambiguates which `IntoExpr` impl to use.
pub fn into_untyped_expr<T, V: IntoExpr<T>>(value: V) -> core::stmt::Expr {
    let expr: stmt::Expr<T> = value.into_expr();
    expr.into()
}