1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use serde_json::Value;
use crate::db::DriverType;
use crate::Result;
pub trait StmtConvert {
fn stmt_convert(&self, index: usize) -> String;
}
impl StmtConvert for DriverType {
fn stmt_convert(&self, index: usize) -> String {
match &self {
DriverType::Postgres => {
format!("${}", index + 1)
}
DriverType::Mysql => "?".to_string(),
DriverType::Sqlite => "?".to_string(),
DriverType::Mssql => {
format!("@p{}", index + 1)
}
DriverType::None => {
panic!("[rbatis] un support none for driver type!")
}
}
}
}
pub trait JsonCodec {
fn try_to_json(self) -> Result<Value>;
}
pub trait RefJsonCodec {
fn try_to_json(&self) -> Result<Value>;
}
pub trait ResultCodec<T> {
fn into_result(self) -> Result<T>;
}