fluidattacks_database_core_domain/cell/
key_field.rs1use alloc::string::String;
2
3use chrono::{DateTime, NaiveDate, Utc};
4
5use super::numeric::Numeric;
6
7#[diagnostic::on_unimplemented(
9 message = "`{Self}` can not be a key column",
10 label = "a key can not be nullable (Option), an array (Vec), JSON or a float",
11 note = "use a non-null scalar for the key: an integer, bool, String, Numeric, a date or a timestamp"
12)]
13pub trait KeyField {}
14
15macro_rules! key_field {
16 ($($t:ty),*) => {$(
17 impl KeyField for $t {}
18 )*};
19}
20
21key_field!(
22 i8,
23 i16,
24 i32,
25 i64,
26 u8,
27 u16,
28 u32,
29 bool,
30 String,
31 NaiveDate,
32 DateTime<Utc>
33);
34
35impl<const P: u8, const S: u8> KeyField for Numeric<P, S> {}