File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -77,8 +77,6 @@ extern crate hex;
7777#[ macro_use]
7878extern crate log;
7979extern crate postgres_protocol;
80- #[ macro_use]
81- #[ macro_reexport]
8280extern crate postgres_shared;
8381
8482use fallible_iterator:: FallibleIterator ;
Original file line number Diff line number Diff line change 22
33#[ doc( inline) ]
44pub 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