diff --git a/src/lib.rs b/src/lib.rs index 31ed551a..0d0372ff 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -279,9 +279,7 @@ impl InnerConnection { options.push(("database".to_owned(), database)); } - try!(conn.stream.write_message(&frontend::StartupMessage { - parameters: &options, - })); + try!(conn.stream.write_message(&frontend::StartupMessage { parameters: &options })); try!(conn.stream.flush()); try!(conn.handle_auth(user)); @@ -337,7 +335,8 @@ impl InnerConnection { } } - fn read_message_with_notification_nonblocking(&mut self) -> std::io::Result> { + fn read_message_with_notification_nonblocking(&mut self) + -> std::io::Result> { debug_assert!(!self.desynchronized); loop { match try_desync!(self, self.stream.read_message_nonblocking()) { @@ -528,7 +527,8 @@ impl InnerConnection { let mut values = vec![]; for (param, ty) in params.iter().zip(param_types) { let mut buf = vec![]; - match try!(param.to_sql_checked(ty, &mut buf, &SessionInfo::new(self)).map_err(Error::Conversion)) { + match try!(param.to_sql_checked(ty, &mut buf, &SessionInfo::new(self)) + .map_err(Error::Conversion)) { IsNull::Yes => values.push(None), IsNull::No => values.push(Some(buf)), } @@ -681,18 +681,16 @@ impl InnerConnection { Some(ref data) => { try!(Option::::from_sql(&Type::Oid, &mut &**data, &ctx) .map_err(Error::Conversion)) - }, + } None => { - try!(Option::::from_sql_null(&Type::Oid, &ctx) - .map_err(Error::Conversion)) - }, + try!(Option::::from_sql_null(&Type::Oid, &ctx).map_err(Error::Conversion)) + } }; let basetype = try!(Oid::from_sql(&Type::Oid, &mut &**row[4].as_ref().unwrap(), &ctx) .map_err(Error::Conversion)); - let schema = try!(String::from_sql(&Type::Name, - &mut &**row[5].as_ref().unwrap(), - &ctx) - .map_err(Error::Conversion)); + let schema = + try!(String::from_sql(&Type::Name, &mut &**row[5].as_ref().unwrap(), &ctx) + .map_err(Error::Conversion)); let relid = try!(Oid::from_sql(&Type::Oid, &mut &**row[6].as_ref().unwrap(), &ctx) .map_err(Error::Conversion)); (name, type_, elem_oid, rngsubtype, basetype, schema, relid) @@ -753,10 +751,8 @@ impl InnerConnection { let ctx = SessionInfo::new(self); let mut variants = vec![]; for row in rows { - variants.push(try!(String::from_sql(&Type::Name, - &mut &**row[0].as_ref().unwrap(), - &ctx) - .map_err(Error::Conversion))); + variants.push(try!(String::from_sql(&Type::Name, &mut &**row[0].as_ref().unwrap(), &ctx) + .map_err(Error::Conversion))); } Ok(variants) @@ -789,10 +785,9 @@ impl InnerConnection { for row in rows { let (name, type_) = { let ctx = SessionInfo::new(self); - let name = try!(String::from_sql(&Type::Name, - &mut &**row[0].as_ref().unwrap(), - &ctx) - .map_err(Error::Conversion)); + let name = + try!(String::from_sql(&Type::Name, &mut &**row[0].as_ref().unwrap(), &ctx) + .map_err(Error::Conversion)); let type_ = try!(Oid::from_sql(&Type::Oid, &mut &**row[1].as_ref().unwrap(), &ctx) .map_err(Error::Conversion)); (name, type_) diff --git a/src/stmt.rs b/src/stmt.rs index ad8fa313..cb3ed996 100644 --- a/src/stmt.rs +++ b/src/stmt.rs @@ -365,7 +365,9 @@ impl<'conn> Statement<'conn> { try!(conn.raw_execute(&self.info.name, "", 0, self.param_types(), params)); let (format, column_formats) = match try!(conn.read_message()) { - backend::Message::CopyOutResponse { format, column_formats } => (format, column_formats), + backend::Message::CopyOutResponse { format, column_formats } => { + (format, column_formats) + } backend::Message::CopyInResponse { .. } => { try!(conn.stream.write_message(&frontend::CopyFail { message: "" })); try!(conn.stream.write_message(&frontend::CopyDone)); @@ -432,14 +434,16 @@ impl<'conn> Statement<'conn> { } backend::Message::ErrorResponse { fields } => { loop { - if let backend::Message::ReadyForQuery { .. } = try!(info.conn.read_message()) { + if let backend::Message::ReadyForQuery { .. } = + try!(info.conn.read_message()) { return DbError::new(fields); } } } _ => { loop { - if let backend::Message::ReadyForQuery { .. } = try!(info.conn.read_message()) { + if let backend::Message::ReadyForQuery { .. } = + try!(info.conn.read_message()) { return Err(Error::Io(bad_response())); } } diff --git a/src/types/bit_vec.rs b/src/types/bit_vec.rs index 2ed262c8..ab4709b8 100644 --- a/src/types/bit_vec.rs +++ b/src/types/bit_vec.rs @@ -21,7 +21,11 @@ impl FromSql for BitVec { } impl ToSql for BitVec { - fn to_sql(&self, _: &Type, mut out: &mut Vec, _: &SessionInfo) -> Result> { + fn to_sql(&self, + _: &Type, + mut out: &mut Vec, + _: &SessionInfo) + -> Result> { try!(types::varbit_to_sql(self.len(), self.to_bytes().into_iter(), out)); Ok(IsNull::No) } diff --git a/src/types/chrono.rs b/src/types/chrono.rs index 1945b682..60d8d15e 100644 --- a/src/types/chrono.rs +++ b/src/types/chrono.rs @@ -12,7 +12,10 @@ fn base() -> NaiveDateTime { } impl FromSql for NaiveDateTime { - fn from_sql(_: &Type, raw: &[u8], _: &SessionInfo) -> Result> { + fn from_sql(_: &Type, + raw: &[u8], + _: &SessionInfo) + -> Result> { let t = try!(types::timestamp_from_sql(raw)); Ok(base() + Duration::microseconds(t)) } @@ -21,7 +24,11 @@ impl FromSql for NaiveDateTime { } impl ToSql for NaiveDateTime { - fn to_sql(&self, _: &Type, w: &mut Vec, _: &SessionInfo) -> Result> { + fn to_sql(&self, + _: &Type, + w: &mut Vec, + _: &SessionInfo) + -> Result> { let time = match (*self - base()).num_microseconds() { Some(time) => time, None => return Err("value too large to transmit".into()), @@ -35,7 +42,10 @@ impl ToSql for NaiveDateTime { } impl FromSql for DateTime { - fn from_sql(type_: &Type, raw: &[u8], info: &SessionInfo) -> Result, Box> { + fn from_sql(type_: &Type, + raw: &[u8], + info: &SessionInfo) + -> Result, Box> { let naive = try!(NaiveDateTime::from_sql(type_, raw, info)); Ok(DateTime::from_utc(naive, UTC)) } @@ -44,7 +54,11 @@ impl FromSql for DateTime { } impl ToSql for DateTime { - fn to_sql(&self, type_: &Type, w: &mut Vec, info: &SessionInfo) -> Result> { + fn to_sql(&self, + type_: &Type, + w: &mut Vec, + info: &SessionInfo) + -> Result> { self.naive_utc().to_sql(type_, w, info) } @@ -53,7 +67,10 @@ impl ToSql for DateTime { } impl FromSql for DateTime { - fn from_sql(type_: &Type, raw: &[u8], info: &SessionInfo) -> Result, Box> { + fn from_sql(type_: &Type, + raw: &[u8], + info: &SessionInfo) + -> Result, Box> { let utc = try!(DateTime::::from_sql(type_, raw, info)); Ok(utc.with_timezone(&Local)) } @@ -62,7 +79,11 @@ impl FromSql for DateTime { } impl ToSql for DateTime { - fn to_sql(&self, type_: &Type, mut w: &mut Vec, info: &SessionInfo) -> Result> { + fn to_sql(&self, + type_: &Type, + mut w: &mut Vec, + info: &SessionInfo) + -> Result> { self.with_timezone(&UTC).to_sql(type_, w, info) } @@ -71,7 +92,10 @@ impl ToSql for DateTime { } impl FromSql for DateTime { - fn from_sql(type_: &Type, raw: &[u8], info: &SessionInfo) -> Result, Box> { + fn from_sql(type_: &Type, + raw: &[u8], + info: &SessionInfo) + -> Result, Box> { let utc = try!(DateTime::::from_sql(type_, raw, info)); Ok(utc.with_timezone(&FixedOffset::east(0))) } @@ -80,7 +104,11 @@ impl FromSql for DateTime { } impl ToSql for DateTime { - fn to_sql(&self, type_: &Type, w: &mut Vec, info: &SessionInfo) -> Result> { + fn to_sql(&self, + type_: &Type, + w: &mut Vec, + info: &SessionInfo) + -> Result> { self.with_timezone(&UTC).to_sql(type_, w, info) } @@ -89,7 +117,10 @@ impl ToSql for DateTime { } impl FromSql for NaiveDate { - fn from_sql(_: &Type, raw: &[u8], _: &SessionInfo) -> Result> { + fn from_sql(_: &Type, + raw: &[u8], + _: &SessionInfo) + -> Result> { let jd = try!(types::date_from_sql(raw)); Ok(base().date() + Duration::days(jd as i64)) } @@ -98,7 +129,11 @@ impl FromSql for NaiveDate { } impl ToSql for NaiveDate { - fn to_sql(&self, _: &Type, w: &mut Vec, _: &SessionInfo) -> Result> { + fn to_sql(&self, + _: &Type, + w: &mut Vec, + _: &SessionInfo) + -> Result> { let jd = (*self - base().date()).num_days(); if jd > i32::max_value() as i64 || jd < i32::min_value() as i64 { return Err("value too large to transmit".into()); @@ -113,7 +148,10 @@ impl ToSql for NaiveDate { } impl FromSql for NaiveTime { - fn from_sql(_: &Type, raw: &[u8], _: &SessionInfo) -> Result> { + fn from_sql(_: &Type, + raw: &[u8], + _: &SessionInfo) + -> Result> { let usec = try!(types::time_from_sql(raw)); Ok(NaiveTime::from_hms(0, 0, 0) + Duration::microseconds(usec)) } @@ -122,7 +160,11 @@ impl FromSql for NaiveTime { } impl ToSql for NaiveTime { - fn to_sql(&self, _: &Type, w: &mut Vec, _: &SessionInfo) -> Result> { + fn to_sql(&self, + _: &Type, + w: &mut Vec, + _: &SessionInfo) + -> Result> { let delta = *self - NaiveTime::from_hms(0, 0, 0); let time = match delta.num_microseconds() { Some(time) => time, diff --git a/src/types/eui48.rs b/src/types/eui48.rs index 534c62bb..01c1752e 100644 --- a/src/types/eui48.rs +++ b/src/types/eui48.rs @@ -7,7 +7,10 @@ use postgres_protocol::types; use types::{FromSql, ToSql, Type, IsNull, SessionInfo}; impl FromSql for MacAddress { - fn from_sql(_: &Type, raw: &[u8], _: &SessionInfo) -> Result> { + fn from_sql(_: &Type, + raw: &[u8], + _: &SessionInfo) + -> Result> { let bytes = try!(types::macaddr_from_sql(raw)); Ok(MacAddress::new(bytes)) } @@ -16,7 +19,11 @@ impl FromSql for MacAddress { } impl ToSql for MacAddress { - fn to_sql(&self, _: &Type, w: &mut Vec, _: &SessionInfo) -> Result> { + fn to_sql(&self, + _: &Type, + w: &mut Vec, + _: &SessionInfo) + -> Result> { let mut bytes = [0; 6]; bytes.copy_from_slice(self.as_bytes()); types::macaddr_to_sql(bytes, w); diff --git a/src/types/mod.rs b/src/types/mod.rs index fa71a71d..d637a8c9 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -47,7 +47,11 @@ macro_rules! to_sql_checked { // WARNING: this function is not considered part of this crate's public API. // It is subject to change at any time. #[doc(hidden)] -pub fn __to_sql_checked(v: &T, ty: &Type, out: &mut Vec, ctx: &SessionInfo) -> Result> +pub fn __to_sql_checked(v: &T, + ty: &Type, + out: &mut Vec, + ctx: &SessionInfo) + -> Result> where T: ToSql { if !T::accepts(ty) { @@ -307,7 +311,10 @@ pub trait FromSql: Sized { /// /// The caller of this method is responsible for ensuring that this type /// is compatible with the Postgres `Type`. - fn from_sql(ty: &Type, raw: &[u8], ctx: &SessionInfo) -> Result>; + fn from_sql(ty: &Type, + raw: &[u8], + ctx: &SessionInfo) + -> Result>; /// Creates a new value of this type from a `NULL` SQL value. /// @@ -327,7 +334,10 @@ pub trait FromSql: Sized { } impl FromSql for Option { - fn from_sql(ty: &Type, raw: &[u8], ctx: &SessionInfo) -> Result, Box> { + fn from_sql(ty: &Type, + raw: &[u8], + ctx: &SessionInfo) + -> Result, Box> { ::from_sql(ty, raw, ctx).map(Some) } @@ -341,7 +351,10 @@ impl FromSql for Option { } impl FromSql for Vec { - fn from_sql(ty: &Type, raw: &[u8], info: &SessionInfo) -> Result, Box> { + fn from_sql(ty: &Type, + raw: &[u8], + info: &SessionInfo) + -> Result, Box> { let member_type = match *ty.kind() { Kind::Array(ref member) => member, _ => panic!("expected array type"), @@ -371,7 +384,10 @@ impl FromSql for Vec { } impl FromSql for Vec { - fn from_sql(_: &Type, raw: &[u8], _: &SessionInfo) -> Result, Box> { + fn from_sql(_: &Type, + raw: &[u8], + _: &SessionInfo) + -> Result, Box> { Ok(types::bytea_from_sql(raw).to_owned()) } @@ -414,7 +430,10 @@ simple_from!(f32, float4_from_sql, Type::Float4); simple_from!(f64, float8_from_sql, Type::Float8); impl FromSql for HashMap> { - fn from_sql(_: &Type, raw: &[u8], _: &SessionInfo) -> Result>, Box> { + fn from_sql(_: &Type, + raw: &[u8], + _: &SessionInfo) + -> Result>, Box> { try!(types::hstore_from_sql(raw)) .map(|(k, v)| (k.to_owned(), v.map(|v| v.to_owned()))) .collect() @@ -501,7 +520,12 @@ pub trait ToSql: fmt::Debug { /// The return value indicates if this value should be represented as /// `NULL`. If this is the case, implementations **must not** write /// anything to `out`. - fn to_sql(&self, ty: &Type, out: &mut Vec, ctx: &SessionInfo) -> Result> where Self: Sized; + fn to_sql(&self, + ty: &Type, + out: &mut Vec, + ctx: &SessionInfo) + -> Result> + where Self: Sized; /// Determines if a value of this type can be converted to the specified /// Postgres `Type`. @@ -511,13 +535,21 @@ pub trait ToSql: fmt::Debug { /// /// *All* implementations of this method should be generated by the /// `to_sql_checked!()` macro. - fn to_sql_checked(&self, ty: &Type, out: &mut Vec, ctx: &SessionInfo) -> Result>; + fn to_sql_checked(&self, + ty: &Type, + out: &mut Vec, + ctx: &SessionInfo) + -> Result>; } impl<'a, T> ToSql for &'a T where T: ToSql { - fn to_sql(&self, ty: &Type, out: &mut Vec, ctx: &SessionInfo) -> Result> { + fn to_sql(&self, + ty: &Type, + out: &mut Vec, + ctx: &SessionInfo) + -> Result> { (*self).to_sql(ty, out, ctx) } @@ -529,7 +561,11 @@ impl<'a, T> ToSql for &'a T } impl ToSql for Option { - fn to_sql(&self, ty: &Type, out: &mut Vec, ctx: &SessionInfo) -> Result> { + fn to_sql(&self, + ty: &Type, + out: &mut Vec, + ctx: &SessionInfo) + -> Result> { match *self { Some(ref val) => val.to_sql(ty, out, ctx), None => Ok(IsNull::Yes), @@ -544,18 +580,20 @@ impl ToSql for Option { } impl<'a, T: ToSql> ToSql for &'a [T] { - fn to_sql(&self, ty: &Type, w: &mut Vec, ctx: &SessionInfo) -> Result> { + fn to_sql(&self, + ty: &Type, + w: &mut Vec, + ctx: &SessionInfo) + -> Result> { let member_type = match *ty.kind() { Kind::Array(ref member) => member, _ => panic!("expected array type"), }; - let dimensions = [ - ArrayDimension { - len: try!(downcast(self.len())), - lower_bound: 1, - } - ]; + let dimensions = [ArrayDimension { + len: try!(downcast(self.len())), + lower_bound: 1, + }]; try!(types::array_to_sql(dimensions.iter().cloned(), true, @@ -582,7 +620,11 @@ impl<'a, T: ToSql> ToSql for &'a [T] { } impl<'a> ToSql for &'a [u8] { - fn to_sql(&self, _: &Type, w: &mut Vec, _: &SessionInfo) -> Result> { + fn to_sql(&self, + _: &Type, + w: &mut Vec, + _: &SessionInfo) + -> Result> { types::bytea_to_sql(*self, w); Ok(IsNull::No) } @@ -593,7 +635,11 @@ impl<'a> ToSql for &'a [u8] { } impl ToSql for Vec { - fn to_sql(&self, ty: &Type, w: &mut Vec, ctx: &SessionInfo) -> Result> { + fn to_sql(&self, + ty: &Type, + w: &mut Vec, + ctx: &SessionInfo) + -> Result> { <&[T] as ToSql>::to_sql(&&**self, ty, w, ctx) } @@ -605,7 +651,11 @@ impl ToSql for Vec { } impl ToSql for Vec { - fn to_sql(&self, ty: &Type, w: &mut Vec, ctx: &SessionInfo) -> Result> { + fn to_sql(&self, + ty: &Type, + w: &mut Vec, + ctx: &SessionInfo) + -> Result> { <&[u8] as ToSql>::to_sql(&&**self, ty, w, ctx) } @@ -617,7 +667,11 @@ impl ToSql for Vec { } impl<'a> ToSql for &'a str { - fn to_sql(&self, _: &Type, w: &mut Vec, _: &SessionInfo) -> Result> { + fn to_sql(&self, + _: &Type, + w: &mut Vec, + _: &SessionInfo) + -> Result> { types::text_to_sql(*self, w); Ok(IsNull::No) } @@ -634,7 +688,11 @@ impl<'a> ToSql for &'a str { } impl ToSql for String { - fn to_sql(&self, ty: &Type, w: &mut Vec, ctx: &SessionInfo) -> Result> { + fn to_sql(&self, + ty: &Type, + w: &mut Vec, + ctx: &SessionInfo) + -> Result> { <&str as ToSql>::to_sql(&&**self, ty, w, ctx) } @@ -670,8 +728,13 @@ simple_to!(f32, float4_to_sql, Type::Float4); simple_to!(f64, float8_to_sql, Type::Float8); impl ToSql for HashMap> { - fn to_sql(&self, _: &Type, w: &mut Vec, _: &SessionInfo) -> Result> { - try!(types::hstore_to_sql(self.iter().map(|(k, v)| (&**k, v.as_ref().map(|v| &**v))), w)); + fn to_sql(&self, + _: &Type, + w: &mut Vec, + _: &SessionInfo) + -> Result> { + try!(types::hstore_to_sql(self.iter().map(|(k, v)| (&**k, v.as_ref().map(|v| &**v))), + w)); Ok(IsNull::No) } diff --git a/src/types/rustc_serialize.rs b/src/types/rustc_serialize.rs index 82a21b1c..6120b35c 100644 --- a/src/types/rustc_serialize.rs +++ b/src/types/rustc_serialize.rs @@ -8,7 +8,10 @@ use std::error::Error; use types::{FromSql, ToSql, IsNull, Type, SessionInfo}; impl FromSql for json::Json { - fn from_sql(ty: &Type, raw: &[u8], _: &SessionInfo) -> Result> { + fn from_sql(ty: &Type, + raw: &[u8], + _: &SessionInfo) + -> Result> { let mut raw = Cursor::new(raw); if let Type::Jsonb = *ty { // We only support version 1 of the jsonb binary format @@ -23,7 +26,11 @@ impl FromSql for json::Json { } impl ToSql for json::Json { - fn to_sql(&self, ty: &Type, mut out: &mut Vec, _: &SessionInfo) -> Result> { + fn to_sql(&self, + ty: &Type, + mut out: &mut Vec, + _: &SessionInfo) + -> Result> { if let Type::Jsonb = *ty { out.push(1); } diff --git a/src/types/serde_json.rs b/src/types/serde_json.rs index 709233ec..e57d7ad8 100644 --- a/src/types/serde_json.rs +++ b/src/types/serde_json.rs @@ -8,7 +8,10 @@ use std::io::Write; use types::{FromSql, ToSql, IsNull, Type, SessionInfo}; impl FromSql for Value { - fn from_sql(ty: &Type, mut raw: &[u8], _: &SessionInfo) -> Result> { + fn from_sql(ty: &Type, + mut raw: &[u8], + _: &SessionInfo) + -> Result> { if let Type::Jsonb = *ty { // We only support version 1 of the jsonb binary format if try!(raw.read_u8()) != 1 { @@ -22,7 +25,11 @@ impl FromSql for Value { } impl ToSql for Value { - fn to_sql(&self, ty: &Type, mut out: &mut Vec, _: &SessionInfo) -> Result> { + fn to_sql(&self, + ty: &Type, + mut out: &mut Vec, + _: &SessionInfo) + -> Result> { if let Type::Jsonb = *ty { out.push(1); } diff --git a/src/types/special.rs b/src/types/special.rs index 79a1e554..4d7ae43e 100644 --- a/src/types/special.rs +++ b/src/types/special.rs @@ -16,7 +16,10 @@ pub enum Date { } impl FromSql for Date { - fn from_sql(ty: &Type, raw: &[u8], ctx: &SessionInfo) -> Result> { + fn from_sql(ty: &Type, + raw: &[u8], + ctx: &SessionInfo) + -> Result> { match try!(types::date_from_sql(raw)) { i32::MAX => Ok(Date::PosInfinity), i32::MIN => Ok(Date::NegInfinity), @@ -29,7 +32,11 @@ impl FromSql for Date { } } impl ToSql for Date { - fn to_sql(&self, ty: &Type, out: &mut Vec, ctx: &SessionInfo) -> Result> { + fn to_sql(&self, + ty: &Type, + out: &mut Vec, + ctx: &SessionInfo) + -> Result> { let value = match *self { Date::PosInfinity => i32::MAX, Date::NegInfinity => i32::MIN, @@ -60,7 +67,10 @@ pub enum Timestamp { } impl FromSql for Timestamp { - fn from_sql(ty: &Type, raw: &[u8], ctx: &SessionInfo) -> Result> { + fn from_sql(ty: &Type, + raw: &[u8], + ctx: &SessionInfo) + -> Result> { match try!(types::timestamp_from_sql(raw)) { i64::MAX => Ok(Timestamp::PosInfinity), i64::MIN => Ok(Timestamp::NegInfinity), @@ -74,7 +84,11 @@ impl FromSql for Timestamp { } impl ToSql for Timestamp { - fn to_sql(&self, ty: &Type, out: &mut Vec, ctx: &SessionInfo) -> Result> { + fn to_sql(&self, + ty: &Type, + out: &mut Vec, + ctx: &SessionInfo) + -> Result> { let value = match *self { Timestamp::PosInfinity => i64::MAX, Timestamp::NegInfinity => i64::MIN, diff --git a/src/types/time.rs b/src/types/time.rs index b38a2e27..f8b3edb9 100644 --- a/src/types/time.rs +++ b/src/types/time.rs @@ -13,7 +13,10 @@ const NSEC_PER_USEC: i64 = 1_000; const TIME_SEC_CONVERSION: i64 = 946684800; impl FromSql for Timespec { - fn from_sql(_: &Type, raw: &[u8], _: &SessionInfo) -> Result> { + fn from_sql(_: &Type, + raw: &[u8], + _: &SessionInfo) + -> Result> { let t = try!(types::timestamp_from_sql(raw)); let mut sec = t / USEC_PER_SEC + TIME_SEC_CONVERSION; let mut usec = t % USEC_PER_SEC; @@ -30,7 +33,11 @@ impl FromSql for Timespec { } impl ToSql for Timespec { - fn to_sql(&self, _: &Type, w: &mut Vec, _: &SessionInfo) -> Result> { + fn to_sql(&self, + _: &Type, + w: &mut Vec, + _: &SessionInfo) + -> Result> { let t = (self.sec - TIME_SEC_CONVERSION) * USEC_PER_SEC + self.nsec as i64 / NSEC_PER_USEC; types::timestamp_to_sql(t, w); Ok(IsNull::No) diff --git a/src/types/uuid.rs b/src/types/uuid.rs index 9e616d77..a9e97fbd 100644 --- a/src/types/uuid.rs +++ b/src/types/uuid.rs @@ -16,7 +16,11 @@ impl FromSql for Uuid { } impl ToSql for Uuid { - fn to_sql(&self, _: &Type, w: &mut Vec, _: &SessionInfo) -> Result> { + fn to_sql(&self, + _: &Type, + w: &mut Vec, + _: &SessionInfo) + -> Result> { types::uuid_to_sql(*self.as_bytes(), w); Ok(IsNull::No) }