11use std:: error:: Error ;
2- use postgres:: types:: { Type , Kind , ToSql , FromSql , IsNull , SessionInfo } ;
3- use postgres_protocol:: types;
2+ use postgres:: types:: { Type , Kind , ToSql , FromSql , IsNull } ;
3+ use postgres_protocol:: { self as protocol , types} ;
44
55use { Range , RangeBound , BoundType , BoundSided , Normalizable } ;
66
77impl < T > FromSql for Range < T > where T : PartialOrd +Normalizable +FromSql {
8- fn from_sql ( ty : & Type , raw : & [ u8 ] , info : & SessionInfo ) -> Result < Range < T > , Box < Error + Sync + Send > > {
8+ fn from_sql ( ty : & Type , raw : & [ u8 ] ) -> Result < Range < T > , Box < Error + Sync + Send > > {
99 let element_type = match ty. kind ( ) {
1010 & Kind :: Range ( ref ty) => ty,
1111 _ => panic ! ( "unexpected type {:?}" , ty)
@@ -14,8 +14,8 @@ impl<T> FromSql for Range<T> where T: PartialOrd+Normalizable+FromSql {
1414 match try!( types:: range_from_sql ( raw) ) {
1515 types:: Range :: Empty => Ok ( Range :: empty ( ) ) ,
1616 types:: Range :: Nonempty ( lower, upper) => {
17- let lower = try!( bound_from_sql ( lower, element_type, info ) ) ;
18- let upper = try!( bound_from_sql ( upper, element_type, info ) ) ;
17+ let lower = try!( bound_from_sql ( lower, element_type) ) ;
18+ let upper = try!( bound_from_sql ( upper, element_type) ) ;
1919 Ok ( Range :: new ( lower, upper) )
2020 }
2121 }
@@ -29,22 +29,22 @@ impl<T> FromSql for Range<T> where T: PartialOrd+Normalizable+FromSql {
2929 }
3030}
3131
32- fn bound_from_sql < T , S > ( bound : types:: RangeBound < Option < & [ u8 ] > > , ty : & Type , info : & SessionInfo ) -> Result < Option < RangeBound < S , T > > , Box < Error + Sync + Send > >
32+ fn bound_from_sql < T , S > ( bound : types:: RangeBound < Option < & [ u8 ] > > , ty : & Type ) -> Result < Option < RangeBound < S , T > > , Box < Error + Sync + Send > >
3333 where T : PartialOrd + Normalizable + FromSql ,
3434 S : BoundSided
3535{
3636 match bound {
3737 types:: RangeBound :: Exclusive ( value) => {
3838 let value = match value {
39- Some ( value) => try!( T :: from_sql ( ty, value, info ) ) ,
40- None => try!( T :: from_sql_null ( ty, info ) ) ,
39+ Some ( value) => try!( T :: from_sql ( ty, value) ) ,
40+ None => try!( T :: from_sql_null ( ty) ) ,
4141 } ;
4242 Ok ( Some ( RangeBound :: new ( value, BoundType :: Exclusive ) ) )
4343 } ,
4444 types:: RangeBound :: Inclusive ( value) => {
4545 let value = match value {
46- Some ( value) => try!( T :: from_sql ( ty, value, info ) ) ,
47- None => try!( T :: from_sql_null ( ty, info ) ) ,
46+ Some ( value) => try!( T :: from_sql ( ty, value) ) ,
47+ None => try!( T :: from_sql_null ( ty) ) ,
4848 } ;
4949 Ok ( Some ( RangeBound :: new ( value, BoundType :: Inclusive ) ) )
5050 } ,
@@ -53,7 +53,7 @@ fn bound_from_sql<T, S>(bound: types::RangeBound<Option<&[u8]>>, ty: &Type, info
5353}
5454
5555impl < T > ToSql for Range < T > where T : PartialOrd +Normalizable +ToSql {
56- fn to_sql ( & self , ty : & Type , mut buf : & mut Vec < u8 > , info : & SessionInfo ) -> Result < IsNull , Box < Error + Sync + Send > > {
56+ fn to_sql ( & self , ty : & Type , buf : & mut Vec < u8 > ) -> Result < IsNull , Box < Error + Sync + Send > > {
5757 let element_type = match ty. kind ( ) {
5858 & Kind :: Range ( ref ty) => ty,
5959 _ => panic ! ( "unexpected type {:?}" , ty)
@@ -62,8 +62,8 @@ impl<T> ToSql for Range<T> where T: PartialOrd+Normalizable+ToSql {
6262 if self . is_empty ( ) {
6363 types:: empty_range_to_sql ( buf) ;
6464 } else {
65- try!( types:: range_to_sql ( |buf| bound_to_sql ( self . lower ( ) , element_type, info , buf) ,
66- |buf| bound_to_sql ( self . upper ( ) , element_type, info , buf) ,
65+ try!( types:: range_to_sql ( |buf| bound_to_sql ( self . lower ( ) , element_type, buf) ,
66+ |buf| bound_to_sql ( self . upper ( ) , element_type, buf) ,
6767 buf) ) ;
6868 }
6969
@@ -80,15 +80,15 @@ impl<T> ToSql for Range<T> where T: PartialOrd+Normalizable+ToSql {
8080 to_sql_checked ! ( ) ;
8181}
8282
83- fn bound_to_sql < S , T > ( bound : Option < & RangeBound < S , T > > , ty : & Type , info : & SessionInfo , buf : & mut Vec < u8 > ) -> Result < types:: RangeBound < types :: IsNull > , Box < Error + Sync + Send > >
83+ fn bound_to_sql < S , T > ( bound : Option < & RangeBound < S , T > > , ty : & Type , buf : & mut Vec < u8 > ) -> Result < types:: RangeBound < protocol :: IsNull > , Box < Error + Sync + Send > >
8484 where S : BoundSided ,
8585 T : ToSql
8686{
8787 match bound {
8888 Some ( bound) => {
89- let null = match try!( bound. value . to_sql ( ty, buf, info ) ) {
90- IsNull :: Yes => types :: IsNull :: Yes ,
91- IsNull :: No => types :: IsNull :: No ,
89+ let null = match try!( bound. value . to_sql ( ty, buf) ) {
90+ IsNull :: Yes => protocol :: IsNull :: Yes ,
91+ IsNull :: No => protocol :: IsNull :: No ,
9292 } ;
9393
9494 match bound. type_ {
0 commit comments