reinhardt_db/orm/query_fields/
traits.rs1use super::lookup::LookupValue;
7use serde::{Deserialize, Serialize};
8
9pub trait Comparable:
11 Clone + Serialize + for<'de> Deserialize<'de> + Send + Sync + Into<LookupValue>
12{
13}
14
15pub trait StringType: Comparable {}
17
18pub trait NumericType: Comparable {}
20
21pub trait DateTimeType: Comparable {}
23
24impl Comparable for String {}
26impl Comparable for i32 {}
27impl Comparable for i64 {}
28impl Comparable for f32 {}
29impl Comparable for f64 {}
30impl Comparable for bool {}
31
32impl StringType for String {}
34
35impl NumericType for i32 {}
37impl NumericType for i64 {}
38impl NumericType for f32 {}
39impl NumericType for f64 {}
40
41#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
43pub struct DateTime {
45 pub timestamp: i64,
47}
48
49impl Comparable for DateTime {}
50impl DateTimeType for DateTime {}
51
52#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
54pub struct Date {
56 pub year: i32,
58 pub month: u8,
60 pub day: u8,
62}
63
64impl Comparable for Date {}
65
66impl Comparable for chrono::NaiveDateTime {}
73impl DateTimeType for chrono::NaiveDateTime {}
74
75impl Comparable for chrono::NaiveDate {}
76impl DateTimeType for chrono::NaiveDate {}
77
78impl Comparable for chrono::NaiveTime {}
79
80impl Comparable for chrono::DateTime<chrono::Utc> {}
81impl DateTimeType for chrono::DateTime<chrono::Utc> {}
82
83impl Comparable for chrono::DateTime<chrono::FixedOffset> {}
84impl DateTimeType for chrono::DateTime<chrono::FixedOffset> {}
85
86impl Comparable for chrono::DateTime<chrono::Local> {}
87impl DateTimeType for chrono::DateTime<chrono::Local> {}