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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
use super::super::base::{KeywordsEscaper, SingleFieldMapper};
use crate::FieldDef;
use std::borrow::Cow;
#[derive(Default, Clone, Debug)]
pub struct MarksMapper;
impl SingleFieldMapper for MarksMapper {
fn map_static<'a>(&'a self, field: &'a FieldDef<'a>, escaper: &dyn KeywordsEscaper) -> Cow<'a, str> {
Cow::Borrowed("?")
}
fn map_static_indexed<'a>(&'a self, field: &'a FieldDef<'a>, escaper: &dyn KeywordsEscaper, index: usize) -> Cow<'a, str> {
Cow::Owned(format!("${}", index + 1))
}
fn map_dynamic_indexed<'a>(&'a self, field: &'a FieldDef<'a>, escaper: &dyn KeywordsEscaper) -> Cow<'a, str> {
Cow::Borrowed("${}")
}
// fn get_value_name(&self) -> &'static str {
// "marks"
// }
// fn map_single<'a>(
// &'a self,
// field: &'a FieldDef<'a>,
// escaper: &dyn KeywordsEscaper,
// indexed: bool,
// ) -> FieldSeg<'a> {
// let ident = format_ident!("{}", field.struct_field.name);
// if indexed {
// FieldSeg::Val(FieldValSeg::IndexedSeg {
// val: Cow::Borrowed("${}"),
// ident,
// })
// } else {
// FieldSeg::Val(FieldValSeg::Seg {
// val: Cow::Borrowed("?"),
// ident,
// })
// }
// }
// fn map(
// &self,
// field: &FieldDef,
// escaper: &dyn KeywordsEscaper,
// leading_comma_type: LeadingCommaType,
// ) -> Cow<'_, str> {
// match leading_comma_type {
// LeadingCommaType::NoLeading => Cow::Borrowed("?"),
// LeadingCommaType::Leading => Cow::Borrowed(",?"),
// LeadingCommaType::CheckedLeading => panic!(
// "MarksMapper: can not generate checked leading comma in compile time for {:?}",
// field
// ),
// }
// }
//
// fn map_indexed<'a>(
// &'a self,
// field: &'a FieldDef<'a>,
// escaper: &dyn KeywordsEscaper,
// leading_comma: LeadingCommaType,
// index: usize,
// ) -> Cow<'a, str> {
// match leading_comma {
// LeadingCommaType::NoLeading => Cow::Owned(format!("${}", index + 1)),
// LeadingCommaType::Leading => Cow::Owned(format!(",${}", index + 1)),
// LeadingCommaType::CheckedLeading => {
// panic!(
// "MarksMapper: can not generate checked leading comma in compile time for {:?}",
// field
// )
// }
// }
// }
// fn map_with_leading_comma<'a>(
// &'a self,
// field: &'a FieldDef<'a>,
// escaper: &dyn KeywordsEscaper,
// ) -> Cow<'a, str> {
// Cow::Borrowed(",?")
// }
// fn map_indexed_with_leading_comma<'a>(
// &'a self,
// field: &'a FieldDef<'a>,
// escaper: &dyn KeywordsEscaper,
// index: usize,
// ) -> Cow<'a, str> {
// Cow::Owned(format!(",${}", index + 1))
// }
// fn map_dynamic(
// &self,
// field: &FieldDef,
// escaper: &dyn KeywordsEscaper,
// leading_comma_type: LeadingCommaType,
// indexed: bool,
// ) -> TokenStream {
// quote! { "?" }
// }
//
// fn map_dynamic_with_leading_comma(
// &self,
// field: &FieldDef,
// escaper: &dyn KeywordsEscaper,
// ) -> TokenStream {
// quote! { ",?" }
// }
//
// fn map_dynamic_indexed(&self, field: &FieldDef, escaper: &dyn KeywordsEscaper) -> TokenStream {
// quote! {format!("${}", index)}
// }
//
// fn map_dynamic_indexed_with_leading_comma(
// &self,
// field: &FieldDef,
// escaper: &dyn KeywordsEscaper,
// ) -> TokenStream {
// quote! {format!(",${}", index)}
// }
}