@@ -2,18 +2,18 @@ extern crate chrono;
22extern crate mysqlclient_sys as ffi;
33
44use self :: chrono:: * ;
5- use std:: error:: Error ;
65use std:: io:: Write ;
76use std:: os:: raw as libc;
87use std:: { mem, ptr, slice} ;
98
109use mysql:: Mysql ;
1110use types:: { Date , Datetime , FromSql , IsNull , Time , Timestamp , ToSql , ToSqlOutput } ;
11+ use { deserialize, serialize} ;
1212
1313macro_rules! mysql_time_impls {
1414 ( $ty: ty) => {
1515 impl ToSql <$ty, Mysql > for ffi:: MYSQL_TIME {
16- fn to_sql<W : Write >( & self , out: & mut ToSqlOutput <W , Mysql >) -> Result < IsNull , Box < Error + Send + Sync >> {
16+ fn to_sql<W : Write >( & self , out: & mut ToSqlOutput <W , Mysql >) -> serialize :: Result {
1717 let bytes = unsafe {
1818 let bytes_ptr = self as * const ffi:: MYSQL_TIME as * const u8 ;
1919 slice:: from_raw_parts( bytes_ptr, mem:: size_of:: <ffi:: MYSQL_TIME >( ) )
@@ -24,7 +24,7 @@ macro_rules! mysql_time_impls {
2424 }
2525
2626 impl FromSql <$ty, Mysql > for ffi:: MYSQL_TIME {
27- fn from_sql( bytes: Option <& [ u8 ] >) -> Result <Self , Box < Error + Send + Sync > > {
27+ fn from_sql( bytes: Option <& [ u8 ] >) -> deserialize :: Result <Self > {
2828 let bytes = not_none!( bytes) ;
2929 let bytes_ptr = bytes. as_ptr( ) as * const ffi:: MYSQL_TIME ;
3030 unsafe {
@@ -47,25 +47,19 @@ mysql_time_impls!(Time);
4747mysql_time_impls ! ( Date ) ;
4848
4949impl ToSql < Datetime , Mysql > for NaiveDateTime {
50- fn to_sql < W : Write > (
51- & self ,
52- out : & mut ToSqlOutput < W , Mysql > ,
53- ) -> Result < IsNull , Box < Error + Send + Sync > > {
50+ fn to_sql < W : Write > ( & self , out : & mut ToSqlOutput < W , Mysql > ) -> serialize:: Result {
5451 <NaiveDateTime as ToSql < Timestamp , Mysql > >:: to_sql ( self , out)
5552 }
5653}
5754
5855impl FromSql < Datetime , Mysql > for NaiveDateTime {
59- fn from_sql ( bytes : Option < & [ u8 ] > ) -> Result < Self , Box < Error + Send + Sync > > {
56+ fn from_sql ( bytes : Option < & [ u8 ] > ) -> deserialize :: Result < Self > {
6057 <NaiveDateTime as FromSql < Timestamp , Mysql > >:: from_sql ( bytes)
6158 }
6259}
6360
6461impl ToSql < Timestamp , Mysql > for NaiveDateTime {
65- fn to_sql < W : Write > (
66- & self ,
67- out : & mut ToSqlOutput < W , Mysql > ,
68- ) -> Result < IsNull , Box < Error + Send + Sync > > {
62+ fn to_sql < W : Write > ( & self , out : & mut ToSqlOutput < W , Mysql > ) -> serialize:: Result {
6963 let mut mysql_time: ffi:: MYSQL_TIME = unsafe { mem:: zeroed ( ) } ;
7064
7165 mysql_time. year = self . year ( ) as libc:: c_uint ;
@@ -81,7 +75,7 @@ impl ToSql<Timestamp, Mysql> for NaiveDateTime {
8175}
8276
8377impl FromSql < Timestamp , Mysql > for NaiveDateTime {
84- fn from_sql ( bytes : Option < & [ u8 ] > ) -> Result < Self , Box < Error + Send + Sync > > {
78+ fn from_sql ( bytes : Option < & [ u8 ] > ) -> deserialize :: Result < Self > {
8579 let mysql_time = <ffi:: MYSQL_TIME as FromSql < Timestamp , Mysql > >:: from_sql ( bytes) ?;
8680
8781 NaiveDate :: from_ymd_opt (
@@ -101,10 +95,7 @@ impl FromSql<Timestamp, Mysql> for NaiveDateTime {
10195}
10296
10397impl ToSql < Time , Mysql > for NaiveTime {
104- fn to_sql < W : Write > (
105- & self ,
106- out : & mut ToSqlOutput < W , Mysql > ,
107- ) -> Result < IsNull , Box < Error + Send + Sync > > {
98+ fn to_sql < W : Write > ( & self , out : & mut ToSqlOutput < W , Mysql > ) -> serialize:: Result {
10899 let mut mysql_time: ffi:: MYSQL_TIME = unsafe { mem:: zeroed ( ) } ;
109100
110101 mysql_time. hour = self . hour ( ) as libc:: c_uint ;
@@ -116,7 +107,7 @@ impl ToSql<Time, Mysql> for NaiveTime {
116107}
117108
118109impl FromSql < Time , Mysql > for NaiveTime {
119- fn from_sql ( bytes : Option < & [ u8 ] > ) -> Result < Self , Box < Error + Send + Sync > > {
110+ fn from_sql ( bytes : Option < & [ u8 ] > ) -> deserialize :: Result < Self > {
120111 let mysql_time = <ffi:: MYSQL_TIME as FromSql < Time , Mysql > >:: from_sql ( bytes) ?;
121112 NaiveTime :: from_hms_opt (
122113 mysql_time. hour as u32 ,
@@ -127,10 +118,7 @@ impl FromSql<Time, Mysql> for NaiveTime {
127118}
128119
129120impl ToSql < Date , Mysql > for NaiveDate {
130- fn to_sql < W : Write > (
131- & self ,
132- out : & mut ToSqlOutput < W , Mysql > ,
133- ) -> Result < IsNull , Box < Error + Send + Sync > > {
121+ fn to_sql < W : Write > ( & self , out : & mut ToSqlOutput < W , Mysql > ) -> serialize:: Result {
134122 let mut mysql_time: ffi:: MYSQL_TIME = unsafe { mem:: zeroed ( ) } ;
135123
136124 mysql_time. year = self . year ( ) as libc:: c_uint ;
@@ -142,7 +130,7 @@ impl ToSql<Date, Mysql> for NaiveDate {
142130}
143131
144132impl FromSql < Date , Mysql > for NaiveDate {
145- fn from_sql ( bytes : Option < & [ u8 ] > ) -> Result < Self , Box < Error + Send + Sync > > {
133+ fn from_sql ( bytes : Option < & [ u8 ] > ) -> deserialize :: Result < Self > {
146134 let mysql_time = <ffi:: MYSQL_TIME as FromSql < Date , Mysql > >:: from_sql ( bytes) ?;
147135 NaiveDate :: from_ymd_opt (
148136 mysql_time. year as i32 ,
0 commit comments