cratestack_sql/values/
into_sql.rs1use cratestack_core::Value;
2
3use super::sql_value::SqlValue;
4
5pub trait IntoSqlValue {
6 fn into_sql_value(self) -> SqlValue;
7}
8
9impl IntoSqlValue for bool {
10 fn into_sql_value(self) -> SqlValue {
11 SqlValue::Bool(self)
12 }
13}
14
15impl IntoSqlValue for i64 {
16 fn into_sql_value(self) -> SqlValue {
17 SqlValue::Int(self)
18 }
19}
20
21impl IntoSqlValue for f64 {
22 fn into_sql_value(self) -> SqlValue {
23 SqlValue::Float(self)
24 }
25}
26
27impl IntoSqlValue for String {
28 fn into_sql_value(self) -> SqlValue {
29 SqlValue::String(self)
30 }
31}
32
33impl IntoSqlValue for &str {
34 fn into_sql_value(self) -> SqlValue {
35 SqlValue::String(self.to_owned())
36 }
37}
38
39impl IntoSqlValue for uuid::Uuid {
40 fn into_sql_value(self) -> SqlValue {
41 SqlValue::Uuid(self)
42 }
43}
44
45impl IntoSqlValue for chrono::DateTime<chrono::Utc> {
46 fn into_sql_value(self) -> SqlValue {
47 SqlValue::DateTime(self)
48 }
49}
50
51impl IntoSqlValue for Value {
52 fn into_sql_value(self) -> SqlValue {
53 SqlValue::Json(self)
54 }
55}
56
57impl IntoSqlValue for cratestack_core::Decimal {
58 fn into_sql_value(self) -> SqlValue {
59 SqlValue::Decimal(self)
60 }
61}