good_ormning_runtime/
sqlite.rs

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