File tree Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -77,8 +77,6 @@ extern crate hex;
77
77
#[ macro_use]
78
78
extern crate log;
79
79
extern crate postgres_protocol;
80
- #[ macro_use]
81
- #[ macro_reexport]
82
80
extern crate postgres_shared;
83
81
84
82
use fallible_iterator:: FallibleIterator ;
Original file line number Diff line number Diff line change 2
2
3
3
#[ doc( inline) ]
4
4
pub use postgres_shared:: types:: * ;
5
+
6
+ /// Generates a simple implementation of `ToSql::accepts` which accepts the
7
+ /// types passed to it.
8
+ #[ macro_export]
9
+ macro_rules! accepts {
10
+ ( $( $expected: pat) ,+) => (
11
+ fn accepts( ty: & $crate:: types:: Type ) -> bool {
12
+ match * ty {
13
+ $( $expected) |+ => true ,
14
+ _ => false
15
+ }
16
+ }
17
+ )
18
+ }
19
+
20
+ /// Generates an implementation of `ToSql::to_sql_checked`.
21
+ ///
22
+ /// All `ToSql` implementations should use this macro.
23
+ #[ macro_export]
24
+ macro_rules! to_sql_checked {
25
+ ( ) => {
26
+ fn to_sql_checked( & self ,
27
+ ty: & $crate:: types:: Type ,
28
+ out: & mut :: std:: vec:: Vec <u8 >,
29
+ ctx: & $crate:: types:: SessionInfo )
30
+ -> :: std:: result:: Result <$crate:: types:: IsNull ,
31
+ Box <:: std:: error:: Error +
32
+ :: std:: marker:: Sync +
33
+ :: std:: marker:: Send >> {
34
+ $crate:: types:: __to_sql_checked( self , ty, out, ctx)
35
+ }
36
+ }
37
+ }
You can’t perform that action at this time.
0 commit comments