fluidattacks-database-core-domain 0.1.0

Database core functional core: database-agnostic table identifiers and types (no I/O)
Documentation
use alloc::string::String;

use chrono::{DateTime, NaiveDate, Utc};

use super::numeric::Numeric;

/// The Rust types a key column can have: non-null scalars.
#[diagnostic::on_unimplemented(
    message = "`{Self}` can not be a key column",
    label = "a key can not be nullable (Option), an array (Vec), JSON or a float",
    note = "use a non-null scalar for the key: an integer, bool, String, Numeric, a date or a timestamp"
)]
pub trait KeyField {}

macro_rules! key_field {
    ($($t:ty),*) => {$(
        impl KeyField for $t {}
    )*};
}

key_field!(
    i8,
    i16,
    i32,
    i64,
    u8,
    u16,
    u32,
    bool,
    String,
    NaiveDate,
    DateTime<Utc>
);

impl<const P: u8, const S: u8> KeyField for Numeric<P, S> {}