good_ormning_runtime/
sqlite.rs

1#[cfg(feature = "chrono")]
2use chrono::{
3    DateTime,
4    Utc,
5    FixedOffset,
6};
7#[cfg(feature = "jiff")]
8use jiff::{
9    Zoned,
10    Timestamp,
11};
12
13pub trait GoodOrmningCustomBool<T> {
14    fn to_sql(value: &T) -> bool;
15    fn from_sql(value: bool) -> Result<T, String>;
16}
17
18pub trait GoodOrmningCustomI32<T> {
19    fn to_sql(value: &T) -> i32;
20    fn from_sql(value: i32) -> Result<T, String>;
21}
22
23pub trait GoodOrmningCustomI64<T> {
24    fn to_sql(value: &T) -> i64;
25    fn from_sql(value: i64) -> Result<T, String>;
26}
27
28pub trait GoodOrmningCustomU32<T> {
29    fn to_sql(value: &T) -> u32;
30    fn from_sql(value: u32) -> Result<T, String>;
31}
32
33pub trait GoodOrmningCustomF32<T> {
34    fn to_sql(value: &T) -> f32;
35    fn from_sql(value: f32) -> Result<T, String>;
36}
37
38pub trait GoodOrmningCustomF64<T> {
39    fn to_sql(value: &T) -> f64;
40    fn from_sql(value: f64) -> Result<T, String>;
41}
42
43pub trait GoodOrmningCustomString<T> {
44    fn to_sql<'a>(value: &'a T) -> String;
45    fn from_sql(value: String) -> Result<T, String>;
46}
47
48pub trait GoodOrmningCustomBytes<T> {
49    fn to_sql<'a>(value: &'a T) -> Vec<u8>;
50    fn from_sql(value: Vec<u8>) -> Result<T, String>;
51}
52
53#[cfg(feature = "chrono")]
54pub trait GoodOrmningCustomUtcTimeChrono<T> {
55    fn to_sql(value: &T) -> DateTime<Utc>;
56    fn from_sql(value: DateTime<Utc>) -> Result<T, String>;
57}
58
59#[cfg(feature = "chrono")]
60pub trait GoodOrmningCustomFixedOffsetTimeChrono<T> {
61    fn to_sql(value: &T) -> DateTime<FixedOffset>;
62    fn from_sql(value: DateTime<FixedOffset>) -> Result<T, String>;
63}
64
65#[cfg(feature = "jiff")]
66pub trait GoodOrmningCustomUtcTimeJiff<T> {
67    fn to_sql(value: &T) -> Timestamp;
68    fn from_sql(value: Timestamp) -> Result<T, String>;
69}
70
71#[cfg(feature = "jiff")]
72pub trait GoodOrmningCustomFixedOffsetTimeJiff<T> {
73    fn to_sql(value: &T) -> Zoned;
74    fn from_sql(value: Zoned) -> Result<T, String>;
75}