From 52dd0b6780a2d09f29556ebb5f0a01e9711fe7b9 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Wed, 28 Nov 2018 19:32:29 -0800 Subject: [PATCH] rustfmt --- postgres-protocol/src/lib.rs | 9 +- postgres-protocol/src/message/frontend.rs | 53 +++++-- postgres-shared/src/error/sqlstate.rs | 45 ++++-- postgres-shared/src/lib.rs | 4 +- postgres-shared/src/params/url.rs | 93 +++++++---- postgres-shared/src/rows.rs | 6 +- postgres-shared/src/types/chrono.rs | 5 +- postgres-shared/src/types/geo.rs | 15 +- postgres-shared/src/types/mod.rs | 6 +- postgres-shared/src/types/type_gen.rs | 4 +- postgres/src/macros.rs | 8 +- postgres/src/notification.rs | 42 +++-- postgres/src/params.rs | 2 +- postgres/src/priv_io.rs | 6 +- postgres/src/stmt.rs | 180 ++++++++-------------- postgres/src/text_rows.rs | 23 ++- postgres/src/transaction.rs | 13 +- postgres/tests/test.rs | 4 +- postgres/tests/types/chrono.rs | 6 +- postgres/tests/types/mod.rs | 6 +- postgres/tests/types/uuid.rs | 4 +- tokio-postgres/src/error/sqlstate.rs | 45 ++++-- 22 files changed, 306 insertions(+), 273 deletions(-) diff --git a/postgres-protocol/src/lib.rs b/postgres-protocol/src/lib.rs index f49165ff..da06a4c3 100644 --- a/postgres-protocol/src/lib.rs +++ b/postgres-protocol/src/lib.rs @@ -9,7 +9,7 @@ //! //! This library assumes that the `client_encoding` backend parameter has been //! set to `UTF8`. It will most likely not behave properly if that is not the case. -#![doc(html_root_url="https://docs.rs/postgres-protocol/0.3")] +#![doc(html_root_url = "https://docs.rs/postgres-protocol/0.3")] #![warn(missing_docs)] extern crate base64; extern crate byteorder; @@ -68,13 +68,16 @@ macro_rules! from_usize { #[inline] fn from_usize(x: usize) -> io::Result<$t> { if x > <$t>::max_value() as usize { - Err(io::Error::new(io::ErrorKind::InvalidInput, "value too large to transmit")) + Err(io::Error::new( + io::ErrorKind::InvalidInput, + "value too large to transmit", + )) } else { Ok(x as $t) } } } - } + }; } from_usize!(i16); diff --git a/postgres-protocol/src/message/frontend.rs b/postgres-protocol/src/message/frontend.rs index a340df0c..a0c20a83 100644 --- a/postgres-protocol/src/message/frontend.rs +++ b/postgres-protocol/src/message/frontend.rs @@ -1,12 +1,12 @@ //! Frontend message serialization. #![allow(missing_docs)] -use byteorder::{WriteBytesExt, BigEndian, ByteOrder}; +use byteorder::{BigEndian, ByteOrder, WriteBytesExt}; use std::error::Error; use std::io; use std::marker; -use {Oid, FromUsize, IsNull, write_nullable}; +use {write_nullable, FromUsize, IsNull, Oid}; pub enum Message<'a> { Bind { @@ -16,24 +16,51 @@ pub enum Message<'a> { values: &'a [Option>], result_formats: &'a [i16], }, - CancelRequest { process_id: i32, secret_key: i32 }, - Close { variant: u8, name: &'a str }, - CopyData { data: &'a [u8] }, + CancelRequest { + process_id: i32, + secret_key: i32, + }, + Close { + variant: u8, + name: &'a str, + }, + CopyData { + data: &'a [u8], + }, CopyDone, - CopyFail { message: &'a str }, - Describe { variant: u8, name: &'a str }, - Execute { portal: &'a str, max_rows: i32 }, + CopyFail { + message: &'a str, + }, + Describe { + variant: u8, + name: &'a str, + }, + Execute { + portal: &'a str, + max_rows: i32, + }, Parse { name: &'a str, query: &'a str, param_types: &'a [Oid], }, - PasswordMessage { password: &'a str }, - Query { query: &'a str }, - SaslInitialResponse { mechanism: &'a str, data: &'a [u8] }, - SaslResponse { data: &'a [u8] }, + PasswordMessage { + password: &'a str, + }, + Query { + query: &'a str, + }, + SaslInitialResponse { + mechanism: &'a str, + data: &'a [u8], + }, + SaslResponse { + data: &'a [u8], + }, SslRequest, - StartupMessage { parameters: &'a [(String, String)] }, + StartupMessage { + parameters: &'a [(String, String)], + }, Sync, Terminate, #[doc(hidden)] diff --git a/postgres-shared/src/error/sqlstate.rs b/postgres-shared/src/error/sqlstate.rs index c8e3ec2e..7dddfc7e 100644 --- a/postgres-shared/src/error/sqlstate.rs +++ b/postgres-shared/src/error/sqlstate.rs @@ -33,7 +33,8 @@ impl SqlState { pub const WARNING_IMPLICIT_ZERO_BIT_PADDING: SqlState = SqlState(Cow::Borrowed("01008")); /// 01003 - pub const WARNING_NULL_VALUE_ELIMINATED_IN_SET_FUNCTION: SqlState = SqlState(Cow::Borrowed("01003")); + pub const WARNING_NULL_VALUE_ELIMINATED_IN_SET_FUNCTION: SqlState = + SqlState(Cow::Borrowed("01003")); /// 01007 pub const WARNING_PRIVILEGE_NOT_GRANTED: SqlState = SqlState(Cow::Borrowed("01007")); @@ -51,7 +52,8 @@ impl SqlState { pub const NO_DATA: SqlState = SqlState(Cow::Borrowed("02000")); /// 02001 - pub const NO_ADDITIONAL_DYNAMIC_RESULT_SETS_RETURNED: SqlState = SqlState(Cow::Borrowed("02001")); + pub const NO_ADDITIONAL_DYNAMIC_RESULT_SETS_RETURNED: SqlState = + SqlState(Cow::Borrowed("02001")); /// 03000 pub const SQL_STATEMENT_NOT_YET_COMPLETE: SqlState = SqlState(Cow::Borrowed("03000")); @@ -66,10 +68,12 @@ impl SqlState { pub const CONNECTION_FAILURE: SqlState = SqlState(Cow::Borrowed("08006")); /// 08001 - pub const SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION: SqlState = SqlState(Cow::Borrowed("08001")); + pub const SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION: SqlState = + SqlState(Cow::Borrowed("08001")); /// 08004 - pub const SQLSERVER_REJECTED_ESTABLISHMENT_OF_SQLCONNECTION: SqlState = SqlState(Cow::Borrowed("08004")); + pub const SQLSERVER_REJECTED_ESTABLISHMENT_OF_SQLCONNECTION: SqlState = + SqlState(Cow::Borrowed("08004")); /// 08007 pub const TRANSACTION_RESOLUTION_UNKNOWN: SqlState = SqlState(Cow::Borrowed("08007")); @@ -105,7 +109,8 @@ impl SqlState { pub const DIAGNOSTICS_EXCEPTION: SqlState = SqlState(Cow::Borrowed("0Z000")); /// 0Z002 - pub const STACKED_DIAGNOSTICS_ACCESSED_WITHOUT_ACTIVE_HANDLER: SqlState = SqlState(Cow::Borrowed("0Z002")); + pub const STACKED_DIAGNOSTICS_ACCESSED_WITHOUT_ACTIVE_HANDLER: SqlState = + SqlState(Cow::Borrowed("0Z002")); /// 20000 pub const CASE_NOT_FOUND: SqlState = SqlState(Cow::Borrowed("20000")); @@ -159,7 +164,8 @@ impl SqlState { pub const INVALID_ARGUMENT_FOR_POWER_FUNCTION: SqlState = SqlState(Cow::Borrowed("2201F")); /// 2201G - pub const INVALID_ARGUMENT_FOR_WIDTH_BUCKET_FUNCTION: SqlState = SqlState(Cow::Borrowed("2201G")); + pub const INVALID_ARGUMENT_FOR_WIDTH_BUCKET_FUNCTION: SqlState = + SqlState(Cow::Borrowed("2201G")); /// 22018 pub const INVALID_CHARACTER_VALUE_FOR_CAST: SqlState = SqlState(Cow::Borrowed("22018")); @@ -192,7 +198,8 @@ impl SqlState { pub const INVALID_ROW_COUNT_IN_LIMIT_CLAUSE: SqlState = SqlState(Cow::Borrowed("2201W")); /// 2201X - pub const INVALID_ROW_COUNT_IN_RESULT_OFFSET_CLAUSE: SqlState = SqlState(Cow::Borrowed("2201X")); + pub const INVALID_ROW_COUNT_IN_RESULT_OFFSET_CLAUSE: SqlState = + SqlState(Cow::Borrowed("2201X")); /// 2202H pub const INVALID_TABLESAMPLE_ARGUMENT: SqlState = SqlState(Cow::Borrowed("2202H")); @@ -303,22 +310,27 @@ impl SqlState { pub const BRANCH_TRANSACTION_ALREADY_ACTIVE: SqlState = SqlState(Cow::Borrowed("25002")); /// 25008 - pub const HELD_CURSOR_REQUIRES_SAME_ISOLATION_LEVEL: SqlState = SqlState(Cow::Borrowed("25008")); + pub const HELD_CURSOR_REQUIRES_SAME_ISOLATION_LEVEL: SqlState = + SqlState(Cow::Borrowed("25008")); /// 25003 - pub const INAPPROPRIATE_ACCESS_MODE_FOR_BRANCH_TRANSACTION: SqlState = SqlState(Cow::Borrowed("25003")); + pub const INAPPROPRIATE_ACCESS_MODE_FOR_BRANCH_TRANSACTION: SqlState = + SqlState(Cow::Borrowed("25003")); /// 25004 - pub const INAPPROPRIATE_ISOLATION_LEVEL_FOR_BRANCH_TRANSACTION: SqlState = SqlState(Cow::Borrowed("25004")); + pub const INAPPROPRIATE_ISOLATION_LEVEL_FOR_BRANCH_TRANSACTION: SqlState = + SqlState(Cow::Borrowed("25004")); /// 25005 - pub const NO_ACTIVE_SQL_TRANSACTION_FOR_BRANCH_TRANSACTION: SqlState = SqlState(Cow::Borrowed("25005")); + pub const NO_ACTIVE_SQL_TRANSACTION_FOR_BRANCH_TRANSACTION: SqlState = + SqlState(Cow::Borrowed("25005")); /// 25006 pub const READ_ONLY_SQL_TRANSACTION: SqlState = SqlState(Cow::Borrowed("25006")); /// 25007 - pub const SCHEMA_AND_DATA_STATEMENT_MIXING_NOT_SUPPORTED: SqlState = SqlState(Cow::Borrowed("25007")); + pub const SCHEMA_AND_DATA_STATEMENT_MIXING_NOT_SUPPORTED: SqlState = + SqlState(Cow::Borrowed("25007")); /// 25P01 pub const NO_ACTIVE_SQL_TRANSACTION: SqlState = SqlState(Cow::Borrowed("25P01")); @@ -345,7 +357,8 @@ impl SqlState { pub const INVALID_PASSWORD: SqlState = SqlState(Cow::Borrowed("28P01")); /// 2B000 - pub const DEPENDENT_PRIVILEGE_DESCRIPTORS_STILL_EXIST: SqlState = SqlState(Cow::Borrowed("2B000")); + pub const DEPENDENT_PRIVILEGE_DESCRIPTORS_STILL_EXIST: SqlState = + SqlState(Cow::Borrowed("2B000")); /// 2BP01 pub const DEPENDENT_OBJECTS_STILL_EXIST: SqlState = SqlState(Cow::Borrowed("2BP01")); @@ -357,7 +370,8 @@ impl SqlState { pub const SQL_ROUTINE_EXCEPTION: SqlState = SqlState(Cow::Borrowed("2F000")); /// 2F005 - pub const S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT: SqlState = SqlState(Cow::Borrowed("2F005")); + pub const S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT: SqlState = + SqlState(Cow::Borrowed("2F005")); /// 2F002 pub const S_R_E_MODIFYING_SQL_DATA_NOT_PERMITTED: SqlState = SqlState(Cow::Borrowed("2F002")); @@ -699,7 +713,8 @@ impl SqlState { pub const FDW_INVALID_OPTION_NAME: SqlState = SqlState(Cow::Borrowed("HV00D")); /// HV090 - pub const FDW_INVALID_STRING_LENGTH_OR_BUFFER_LENGTH: SqlState = SqlState(Cow::Borrowed("HV090")); + pub const FDW_INVALID_STRING_LENGTH_OR_BUFFER_LENGTH: SqlState = + SqlState(Cow::Borrowed("HV090")); /// HV00A pub const FDW_INVALID_STRING_FORMAT: SqlState = SqlState(Cow::Borrowed("HV00A")); diff --git a/postgres-shared/src/lib.rs b/postgres-shared/src/lib.rs index 521779b3..84506f7d 100644 --- a/postgres-shared/src/lib.rs +++ b/postgres-shared/src/lib.rs @@ -1,15 +1,15 @@ #![allow(unknown_lints)] // for clippy -extern crate hex; extern crate fallible_iterator; +extern crate hex; extern crate phf; extern crate postgres_protocol; pub mod error; pub mod params; -pub mod types; pub mod rows; pub mod stmt; +pub mod types; /// Contains information necessary to cancel queries for a session. #[derive(Copy, Clone, Debug)] diff --git a/postgres-shared/src/params/url.rs b/postgres-shared/src/params/url.rs index 549beebf..e965f215 100644 --- a/postgres-shared/src/params/url.rs +++ b/postgres-shared/src/params/url.rs @@ -7,8 +7,8 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::str::FromStr; use hex::FromHex; +use std::str::FromStr; pub struct Url { pub scheme: String, @@ -128,31 +128,29 @@ fn decode_inner(c: &str, full_url: bool) -> DecodeResult { let bytes = match (iter.next(), iter.next()) { (Some(one), Some(two)) => [one, two], _ => { - return Err( - "Malformed input: found '%' without two \ - trailing bytes" - .to_owned(), - ) + return Err("Malformed input: found '%' without two \ + trailing bytes" + .to_owned()) } }; let bytes_from_hex = match Vec::::from_hex(&bytes) { Ok(b) => b, _ => { - return Err( - "Malformed input: found '%' followed by \ + return Err("Malformed input: found '%' followed by \ invalid hex values. Character '%' must \ escaped." - .to_owned(), - ) + .to_owned()) } }; // Only decode some characters if full_url: match bytes_from_hex[0] as char { // gen-delims: - ':' | '/' | '?' | '#' | '[' | ']' | '@' | '!' | '$' | '&' | '"' | - '(' | ')' | '*' | '+' | ',' | ';' | '=' if full_url => { + ':' | '/' | '?' | '#' | '[' | ']' | '@' | '!' | '$' | '&' | '"' + | '(' | ')' | '*' | '+' | ',' | ';' | '=' + if full_url => + { out.push('%'); out.push(bytes[0] as char); out.push(bytes[1] as char); @@ -221,18 +219,18 @@ pub fn get_scheme(rawurl: &str) -> DecodeResult<(&str, &str)> { // returns userinfo, host, port, and unparsed part, or an error fn get_authority(rawurl: &str) -> DecodeResult<(Option, &str, Option, &str)> { enum State { - Start, // starting state + Start, // starting state PassHostPort, // could be in user or port - Ip6Port, // either in ipv6 host or port - Ip6Host, // are in an ipv6 host - InHost, // are in a host - may be ipv6, but don't know yet - InPort, // are in port + Ip6Port, // either in ipv6 host or port + Ip6Host, // are in an ipv6 host + InHost, // are in a host - may be ipv6, but don't know yet + InPort, // are in port } #[derive(Clone, PartialEq)] enum Input { - Digit, // all digits - Hex, // digits and letters a-f + Digit, // all digits + Hex, // digits and letters a-f Unreserved, // all other legal characters } @@ -263,8 +261,23 @@ fn get_authority(rawurl: &str) -> DecodeResult<(Option, &str, Option { // separators, don't change anything } @@ -366,26 +379,42 @@ fn get_authority(rawurl: &str) -> DecodeResult<(Option, &str, Option None, - opt => { - match opt.and_then(|p| FromStr::from_str(p).ok()) { - None => return Err(format!("Failed to parse port: {:?}", port)), - opt => opt, - } - } + opt => match opt.and_then(|p| FromStr::from_str(p).ok()) { + None => return Err(format!("Failed to parse port: {:?}", port)), + opt => opt, + }, }; Ok((userinfo, host, port, rest)) } - // returns the path and unparsed part of url, or an error fn get_path(rawurl: &str, is_authority: bool) -> DecodeResult<(String, &str)> { let len = rawurl.len(); let mut end = len; for (i, c) in rawurl.chars().enumerate() { match c { - 'A'...'Z' | 'a'...'z' | '0'...'9' | '&' | '\'' | '(' | ')' | '.' | '@' | ':' | - '%' | '/' | '+' | '!' | '*' | ',' | ';' | '=' | '_' | '-' | '~' => continue, + 'A'...'Z' + | 'a'...'z' + | '0'...'9' + | '&' + | '\'' + | '(' + | ')' + | '.' + | '@' + | ':' + | '%' + | '/' + | '+' + | '!' + | '*' + | ',' + | ';' + | '=' + | '_' + | '-' + | '~' => continue, '?' | '#' => { end = i; break; @@ -395,9 +424,7 @@ fn get_path(rawurl: &str, is_authority: bool) -> DecodeResult<(String, &str)> { } if is_authority && end != 0 && !rawurl.starts_with('/') { - Err( - "Non-empty path must begin with '/' in presence of authority.".to_owned(), - ) + Err("Non-empty path must begin with '/' in presence of authority.".to_owned()) } else { Ok((decode_component(&rawurl[0..end])?, &rawurl[end..len])) } diff --git a/postgres-shared/src/rows.rs b/postgres-shared/src/rows.rs index 48de5360..2b0f8860 100644 --- a/postgres-shared/src/rows.rs +++ b/postgres-shared/src/rows.rs @@ -59,11 +59,7 @@ where } } -impl<'a, T> RowIndex for &'a T -where - T: ?Sized + Sealed, -{ -} +impl<'a, T> RowIndex for &'a T where T: ?Sized + Sealed {} #[doc(hidden)] pub struct RowData { diff --git a/postgres-shared/src/types/chrono.rs b/postgres-shared/src/types/chrono.rs index 0f305ea1..2ab7da3b 100644 --- a/postgres-shared/src/types/chrono.rs +++ b/postgres-shared/src/types/chrono.rs @@ -1,7 +1,8 @@ extern crate chrono; -use self::chrono::{DateTime, Duration, FixedOffset, Local, NaiveDate, NaiveDateTime, NaiveTime, - Utc}; +use self::chrono::{ + DateTime, Duration, FixedOffset, Local, NaiveDate, NaiveDateTime, NaiveTime, Utc, +}; use postgres_protocol::types; use std::error::Error; diff --git a/postgres-shared/src/types/geo.rs b/postgres-shared/src/types/geo.rs index c09b0c56..82f9d317 100644 --- a/postgres-shared/src/types/geo.rs +++ b/postgres-shared/src/types/geo.rs @@ -30,8 +30,14 @@ impl<'a> FromSql<'a> for Rect { fn from_sql(_: &Type, raw: &[u8]) -> Result> { let rect = types::box_from_sql(raw)?; Ok(Rect { - min: Coordinate { x: rect.lower_left().x(), y: rect.lower_left().y(), }, - max: Coordinate { x: rect.upper_right().x(), y: rect.upper_right().y(), }, + min: Coordinate { + x: rect.lower_left().x(), + y: rect.lower_left().y(), + }, + max: Coordinate { + x: rect.upper_right().x(), + y: rect.upper_right().y(), + }, }) } @@ -51,7 +57,10 @@ impl ToSql for Rect { impl<'a> FromSql<'a> for LineString { fn from_sql(_: &Type, raw: &[u8]) -> Result> { let path = types::path_from_sql(raw)?; - let points = path.points().map(|p| Coordinate { x: p.x(), y: p.y() }).collect()?; + let points = path + .points() + .map(|p| Coordinate { x: p.x(), y: p.y() }) + .collect()?; Ok(LineString(points)) } diff --git a/postgres-shared/src/types/mod.rs b/postgres-shared/src/types/mod.rs index 62772080..9fcfef27 100644 --- a/postgres-shared/src/types/mod.rs +++ b/postgres-shared/src/types/mod.rs @@ -337,11 +337,7 @@ pub trait FromSql<'a>: Sized { /// This is primarily useful for trait bounds on functions. pub trait FromSqlOwned: for<'a> FromSql<'a> {} -impl FromSqlOwned for T -where - T: for<'a> FromSql<'a>, -{ -} +impl FromSqlOwned for T where T: for<'a> FromSql<'a> {} impl<'a, T: FromSql<'a>> FromSql<'a> for Option { fn from_sql(ty: &Type, raw: &'a [u8]) -> Result, Box> { diff --git a/postgres-shared/src/types/type_gen.rs b/postgres-shared/src/types/type_gen.rs index 3992112e..4ce0c5fb 100644 --- a/postgres-shared/src/types/type_gen.rs +++ b/postgres-shared/src/types/type_gen.rs @@ -1,7 +1,7 @@ // Autogenerated file - DO NOT EDIT use std::sync::Arc; -use types::{Type, Oid, Kind}; +use types::{Kind, Oid, Type}; #[derive(PartialEq, Eq, Debug)] pub struct Other { @@ -1834,4 +1834,4 @@ impl Type { /// REGROLE[] pub const REGROLE_ARRAY: Type = Type(Inner::RegroleArray); -} \ No newline at end of file +} diff --git a/postgres/src/macros.rs b/postgres/src/macros.rs index ba6d11ff..939a0344 100644 --- a/postgres/src/macros.rs +++ b/postgres/src/macros.rs @@ -19,21 +19,21 @@ macro_rules! check_desync { } macro_rules! bad_response { - ($s:expr) => ({ + ($s:expr) => {{ debug!("Bad response at {}:{}", file!(), line!()); $s.desynchronized = true; return Err(::bad_response().into()); - }) + }}; } #[cfg(feature = "no-logging")] macro_rules! debug { - ($($t:tt)*) => {} + ($($t:tt)*) => {}; } #[cfg(feature = "no-logging")] macro_rules! info { - ($($t:tt)*) => {} + ($($t:tt)*) => {}; } /// Generates a simple implementation of `ToSql::accepts` which accepts the diff --git a/postgres/src/notification.rs b/postgres/src/notification.rs index addbd748..73eb9862 100644 --- a/postgres/src/notification.rs +++ b/postgres/src/notification.rs @@ -1,17 +1,17 @@ //! Asynchronous notifications. +use error::DbError; use fallible_iterator::{FallibleIterator, IntoFallibleIterator}; +use postgres_protocol::message::backend::{self, ErrorFields}; use std::fmt; use std::time::Duration; -use postgres_protocol::message::backend::{self, ErrorFields}; -use error::DbError; #[doc(inline)] use postgres_shared; pub use postgres_shared::Notification; -use {desynchronized, Result, Connection}; use error::Error; +use {desynchronized, Connection, Result}; /// Notifications from the Postgres backend. pub struct Notifications<'conn> { @@ -105,13 +105,11 @@ impl<'a> FallibleIterator for Iter<'a> { } match conn.read_message_with_notification_nonblocking() { - Ok(Some(backend::Message::NotificationResponse(body))) => { - Ok(Some(Notification { - process_id: body.process_id(), - channel: body.channel()?.to_owned(), - payload: body.message()?.to_owned(), - })) - } + Ok(Some(backend::Message::NotificationResponse(body))) => Ok(Some(Notification { + process_id: body.process_id(), + channel: body.channel()?.to_owned(), + payload: body.message()?.to_owned(), + })), Ok(Some(backend::Message::ErrorResponse(body))) => Err(err(&mut body.fields())), Ok(None) => Ok(None), Err(err) => Err(err.into()), @@ -145,13 +143,11 @@ impl<'a> FallibleIterator for BlockingIter<'a> { } match conn.read_message_with_notification() { - Ok(backend::Message::NotificationResponse(body)) => { - Ok(Some(Notification { - process_id: body.process_id(), - channel: body.channel()?.to_owned(), - payload: body.message()?.to_owned(), - })) - } + Ok(backend::Message::NotificationResponse(body)) => Ok(Some(Notification { + process_id: body.process_id(), + channel: body.channel()?.to_owned(), + payload: body.message()?.to_owned(), + })), Ok(backend::Message::ErrorResponse(body)) => Err(err(&mut body.fields())), Err(err) => Err(err.into()), _ => unreachable!(), @@ -182,13 +178,11 @@ impl<'a> FallibleIterator for TimeoutIter<'a> { } match conn.read_message_with_notification_timeout(self.timeout) { - Ok(Some(backend::Message::NotificationResponse(body))) => { - Ok(Some(Notification { - process_id: body.process_id(), - channel: body.channel()?.to_owned(), - payload: body.message()?.to_owned(), - })) - } + Ok(Some(backend::Message::NotificationResponse(body))) => Ok(Some(Notification { + process_id: body.process_id(), + channel: body.channel()?.to_owned(), + payload: body.message()?.to_owned(), + })), Ok(Some(backend::Message::ErrorResponse(body))) => Err(err(&mut body.fields())), Ok(None) => Ok(None), Err(err) => Err(err.into()), diff --git a/postgres/src/params.rs b/postgres/src/params.rs index eb521f10..29e51228 100644 --- a/postgres/src/params.rs +++ b/postgres/src/params.rs @@ -1,3 +1,3 @@ //! Connection parameters -pub use postgres_shared::params::{Builder, ConnectParams, User, Host, IntoConnectParams}; +pub use postgres_shared::params::{Builder, ConnectParams, Host, IntoConnectParams, User}; diff --git a/postgres/src/priv_io.rs b/postgres/src/priv_io.rs index b761910b..c0e3a131 100644 --- a/postgres/src/priv_io.rs +++ b/postgres/src/priv_io.rs @@ -59,7 +59,8 @@ impl MessageStream { fn read_in(&mut self) -> io::Result<()> { self.in_buf.reserve(1); - match self.stream + match self + .stream .get_mut() .read(unsafe { self.in_buf.bytes_mut() }) { @@ -206,8 +207,7 @@ fn open_socket(params: &ConnectParams) -> Result { io::ErrorKind::InvalidInput, "could not resolve any addresses", ) - }) - .into()) + }).into()) } #[cfg(unix)] Host::Unix(ref path) => { diff --git a/postgres/src/stmt.rs b/postgres/src/stmt.rs index 500da808..640cbcb2 100644 --- a/postgres/src/stmt.rs +++ b/postgres/src/stmt.rs @@ -1,20 +1,20 @@ //! Prepared statements use fallible_iterator::FallibleIterator; +use postgres_protocol::message::{backend, frontend}; +use postgres_shared::rows::RowData; use std::cell::Cell; use std::collections::VecDeque; use std::fmt; use std::io::{self, Read, Write}; use std::sync::Arc; -use postgres_protocol::message::{backend, frontend}; -use postgres_shared::rows::RowData; #[doc(inline)] pub use postgres_shared::stmt::Column; -use types::{Type, ToSql}; -use rows::{Rows, LazyRows}; +use rows::{LazyRows, Rows}; use transaction::Transaction; +use types::{ToSql, Type}; use {bad_response, err, Connection, Result, StatementInfo}; /// A prepared statement. @@ -135,13 +135,7 @@ impl<'conn> Statement<'conn> { pub fn execute(&self, params: &[&ToSql]) -> Result { let mut conn = self.conn.0.borrow_mut(); check_desync!(conn); - conn.raw_execute( - &self.info.name, - "", - 0, - self.param_types(), - params, - )?; + conn.raw_execute(&self.info.name, "", 0, self.param_types(), params)?; let num; loop { @@ -163,9 +157,8 @@ impl<'conn> Statement<'conn> { conn.stream.write_message(|buf| { frontend::copy_fail("COPY queries cannot be directly executed", buf) })?; - conn.stream.write_message( - |buf| Ok::<(), io::Error>(frontend::sync(buf)), - )?; + conn.stream + .write_message(|buf| Ok::<(), io::Error>(frontend::sync(buf)))?; conn.stream.flush()?; } backend::Message::CopyOutResponse(_) => { @@ -269,7 +262,7 @@ impl<'conn> Statement<'conn> { assert!( self.conn as *const _ == trans.conn() as *const _, "the `Transaction` passed to `lazy_query` must be associated with the same \ - `Connection` as the `Statement`" + `Connection` as the `Statement`" ); let conn = self.conn.0.borrow(); check_desync!(conn); @@ -284,12 +277,8 @@ impl<'conn> Statement<'conn> { let portal_name = format!("{}p{}", self.info.name, id); let mut rows = VecDeque::new(); - let more_rows = self.inner_query( - &portal_name, - row_limit, - params, - |row| rows.push_back(row), - )?; + let more_rows = + self.inner_query(&portal_name, row_limit, params, |row| rows.push_back(row))?; Ok(LazyRows::new( self, rows, @@ -324,36 +313,29 @@ impl<'conn> Statement<'conn> { /// ``` pub fn copy_in(&self, params: &[&ToSql], r: &mut R) -> Result { let mut conn = self.conn.0.borrow_mut(); - conn.raw_execute( - &self.info.name, - "", - 0, - self.param_types(), - params, - )?; + conn.raw_execute(&self.info.name, "", 0, self.param_types(), params)?; let (format, column_formats) = match conn.read_message()? { backend::Message::CopyInResponse(body) => { let format = body.format(); - let column_formats = body.column_formats().map(|f| Format::from_u16(f)).collect()?; + let column_formats = body + .column_formats() + .map(|f| Format::from_u16(f)) + .collect()?; (format, column_formats) } backend::Message::ErrorResponse(body) => { conn.wait_for_ready()?; return Err(err(&mut body.fields())); } - _ => { - loop { - if let backend::Message::ReadyForQuery(_) = conn.read_message()? { - return Err( - io::Error::new( - io::ErrorKind::InvalidInput, - "called `copy_in` on a non-`COPY FROM STDIN` statement", - ).into(), - ); - } + _ => loop { + if let backend::Message::ReadyForQuery(_) = conn.read_message()? { + return Err(io::Error::new( + io::ErrorKind::InvalidInput, + "called `copy_in` on a non-`COPY FROM STDIN` statement", + ).into()); } - } + }, }; let info = CopyInfo { @@ -366,20 +348,16 @@ impl<'conn> Statement<'conn> { match fill_copy_buf(&mut buf, r, &info) { Ok(0) => break, Ok(len) => { - conn.stream.write_message( - |out| frontend::copy_data(&buf[..len], out), - )?; + conn.stream + .write_message(|out| frontend::copy_data(&buf[..len], out))?; } Err(err) => { - conn.stream.write_message( - |buf| frontend::copy_fail("", buf), - )?; - conn.stream.write_message(|buf| { - Ok::<(), io::Error>(frontend::copy_done(buf)) - })?; - conn.stream.write_message( - |buf| Ok::<(), io::Error>(frontend::sync(buf)), - )?; + conn.stream + .write_message(|buf| frontend::copy_fail("", buf))?; + conn.stream + .write_message(|buf| Ok::<(), io::Error>(frontend::copy_done(buf)))?; + conn.stream + .write_message(|buf| Ok::<(), io::Error>(frontend::sync(buf)))?; conn.stream.flush()?; match conn.read_message()? { backend::Message::ErrorResponse(_) => { @@ -396,12 +374,10 @@ impl<'conn> Statement<'conn> { } } - conn.stream.write_message(|buf| { - Ok::<(), io::Error>(frontend::copy_done(buf)) - })?; - conn.stream.write_message( - |buf| Ok::<(), io::Error>(frontend::sync(buf)), - )?; + conn.stream + .write_message(|buf| Ok::<(), io::Error>(frontend::copy_done(buf)))?; + conn.stream + .write_message(|buf| Ok::<(), io::Error>(frontend::sync(buf)))?; conn.stream.flush()?; let num = match conn.read_message()? { @@ -444,30 +420,24 @@ impl<'conn> Statement<'conn> { /// ``` pub fn copy_out<'a, W: WriteWithInfo>(&'a self, params: &[&ToSql], w: &mut W) -> Result { let mut conn = self.conn.0.borrow_mut(); - conn.raw_execute( - &self.info.name, - "", - 0, - self.param_types(), - params, - )?; + conn.raw_execute(&self.info.name, "", 0, self.param_types(), params)?; let (format, column_formats) = match conn.read_message()? { backend::Message::CopyOutResponse(body) => { let format = body.format(); - let column_formats = body.column_formats().map(|f| Format::from_u16(f)).collect()?; + let column_formats = body + .column_formats() + .map(|f| Format::from_u16(f)) + .collect()?; (format, column_formats) } backend::Message::CopyInResponse(_) => { - conn.stream.write_message( - |buf| frontend::copy_fail("", buf), - )?; - conn.stream.write_message(|buf| { - Ok::<(), io::Error>(frontend::copy_done(buf)) - })?; - conn.stream.write_message( - |buf| Ok::<(), io::Error>(frontend::sync(buf)), - )?; + conn.stream + .write_message(|buf| frontend::copy_fail("", buf))?; + conn.stream + .write_message(|buf| Ok::<(), io::Error>(frontend::copy_done(buf)))?; + conn.stream + .write_message(|buf| Ok::<(), io::Error>(frontend::sync(buf)))?; conn.stream.flush()?; match conn.read_message()? { backend::Message::ErrorResponse(_) => { @@ -479,29 +449,23 @@ impl<'conn> Statement<'conn> { } } conn.wait_for_ready()?; - return Err( - io::Error::new( - io::ErrorKind::InvalidInput, - "called `copy_out` on a non-`COPY TO STDOUT` statement", - ).into(), - ); + return Err(io::Error::new( + io::ErrorKind::InvalidInput, + "called `copy_out` on a non-`COPY TO STDOUT` statement", + ).into()); } backend::Message::ErrorResponse(body) => { conn.wait_for_ready()?; return Err(err(&mut body.fields())); } - _ => { - loop { - if let backend::Message::ReadyForQuery(_) = conn.read_message()? { - return Err( - io::Error::new( - io::ErrorKind::InvalidInput, - "called `copy_out` on a non-`COPY TO STDOUT` statement", - ).into(), - ); - } + _ => loop { + if let backend::Message::ReadyForQuery(_) = conn.read_message()? { + return Err(io::Error::new( + io::ErrorKind::InvalidInput, + "called `copy_out` on a non-`COPY TO STDOUT` statement", + ).into()); } - } + }, }; let info = CopyInfo { @@ -517,15 +481,11 @@ impl<'conn> Statement<'conn> { while !data.is_empty() { match w.write_with_info(data, &info) { Ok(n) => data = &data[n..], - Err(e) => { - loop { - if let backend::Message::ReadyForQuery(_) = - conn.read_message()? - { - return Err(e.into()); - } + Err(e) => loop { + if let backend::Message::ReadyForQuery(_) = conn.read_message()? { + return Err(e.into()); } - } + }, } } } @@ -534,20 +494,16 @@ impl<'conn> Statement<'conn> { count = parse_update_count(body.tag()?); break; } - backend::Message::ErrorResponse(body) => { - loop { - if let backend::Message::ReadyForQuery(_) = conn.read_message()? { - return Err(err(&mut body.fields())); - } + backend::Message::ErrorResponse(body) => loop { + if let backend::Message::ReadyForQuery(_) = conn.read_message()? { + return Err(err(&mut body.fields())); } - } - _ => { - loop { - if let backend::Message::ReadyForQuery(_) = conn.read_message()? { - return Err(bad_response().into()); - } + }, + _ => loop { + if let backend::Message::ReadyForQuery(_) = conn.read_message()? { + return Err(bad_response().into()); } - } + }, } } diff --git a/postgres/src/text_rows.rs b/postgres/src/text_rows.rs index fd3562c7..678e98a5 100644 --- a/postgres/src/text_rows.rs +++ b/postgres/src/text_rows.rs @@ -8,8 +8,8 @@ use std::str; #[doc(inline)] pub use postgres_shared::rows::RowIndex; -use stmt::{Column}; -use {Result, error}; +use stmt::Column; +use {error, Result}; /// The resulting rows of a query. pub struct TextRows { @@ -89,11 +89,9 @@ impl<'a> Iterator for Iter<'a> { type Item = TextRow<'a>; fn next(&mut self) -> Option> { - self.iter.next().map(|row| { - TextRow { - columns: self.columns, - data: row, - } + self.iter.next().map(|row| TextRow { + columns: self.columns, + data: row, }) } @@ -104,11 +102,9 @@ impl<'a> Iterator for Iter<'a> { impl<'a> DoubleEndedIterator for Iter<'a> { fn next_back(&mut self) -> Option> { - self.iter.next_back().map(|row| { - TextRow { - columns: self.columns, - data: row, - } + self.iter.next_back().map(|row| TextRow { + columns: self.columns, + data: row, }) } } @@ -188,7 +184,8 @@ impl<'a> TextRow<'a> { None => return None, }; - self.data.get(idx) + self.data + .get(idx) .map(|s| str::from_utf8(s).map_err(|e| error::conversion(Box::new(e)))) } } diff --git a/postgres/src/transaction.rs b/postgres/src/transaction.rs index 1dfdc7d3..b00593a0 100644 --- a/postgres/src/transaction.rs +++ b/postgres/src/transaction.rs @@ -4,8 +4,8 @@ use std::cell::Cell; use std::fmt; use rows::Rows; -use text_rows::TextRows; use stmt::Statement; +use text_rows::TextRows; use types::ToSql; use {bad_response, Connection, Result}; @@ -226,10 +226,9 @@ impl<'conn> Transaction<'conn> { } /// Like `Connection::batch_execute`. - #[deprecated(since="0.15.3", note="please use `simple_query` instead")] + #[deprecated(since = "0.15.3", note = "please use `simple_query` instead")] pub fn batch_execute(&self, query: &str) -> Result<()> { - self.simple_query(query) - .map(|_| ()) + self.simple_query(query).map(|_| ()) } /// Like `Connection::simple_query`. @@ -255,7 +254,8 @@ impl<'conn> Transaction<'conn> { /// Panics if there is an active nested transaction. #[inline] pub fn savepoint<'a, I>(&'a self, name: I) -> Result> - where I: Into + where + I: Into, { self._savepoint(name.into()) } @@ -292,8 +292,7 @@ impl<'conn> Transaction<'conn> { pub fn set_config(&self, config: &Config) -> Result<()> { let mut command = "SET TRANSACTION".to_owned(); config.build_command(&mut command); - self.simple_query(&command) - .map(|_| ()) + self.simple_query(&command).map(|_| ()) } /// Determines if the transaction is currently set to commit or roll back. diff --git a/postgres/tests/test.rs b/postgres/tests/test.rs index 753d9d9a..3b8ee384 100644 --- a/postgres/tests/test.rs +++ b/postgres/tests/test.rs @@ -1365,8 +1365,8 @@ fn test_rows_index() { #[test] fn test_type_names() { let conn = Connection::connect("postgres://postgres@localhost:5433", TlsMode::None).unwrap(); - let stmt = - conn.prepare( + let stmt = conn + .prepare( "SELECT t.oid, t.typname FROM pg_catalog.pg_type t, pg_namespace n WHERE n.oid = t.typnamespace diff --git a/postgres/tests/types/chrono.rs b/postgres/tests/types/chrono.rs index 22bd7eef..3d5ef64d 100644 --- a/postgres/tests/types/chrono.rs +++ b/postgres/tests/types/chrono.rs @@ -1,6 +1,6 @@ extern crate chrono; -use self::chrono::{TimeZone, NaiveDate, NaiveTime, NaiveDateTime, DateTime, Utc}; +use self::chrono::{DateTime, NaiveDate, NaiveDateTime, NaiveTime, TimeZone, Utc}; use types::test_type; use postgres::types::{Date, Timestamp}; @@ -9,9 +9,7 @@ use postgres::types::{Date, Timestamp}; fn test_naive_date_time_params() { fn make_check<'a>(time: &'a str) -> (Option, &'a str) { ( - Some( - NaiveDateTime::parse_from_str(time, "'%Y-%m-%d %H:%M:%S.%f'").unwrap(), - ), + Some(NaiveDateTime::parse_from_str(time, "'%Y-%m-%d %H:%M:%S.%f'").unwrap()), time, ) } diff --git a/postgres/tests/types/mod.rs b/postgres/tests/types/mod.rs index e95945b3..0a0be538 100644 --- a/postgres/tests/types/mod.rs +++ b/postgres/tests/types/mod.rs @@ -364,7 +364,8 @@ fn test_slice() { INSERT INTO foo (f) VALUES ('a'), ('b'), ('c'), ('d');", ).unwrap(); - let stmt = conn.prepare("SELECT f FROM foo WHERE id = ANY($1)") + let stmt = conn + .prepare("SELECT f FROM foo WHERE id = ANY($1)") .unwrap(); let result = stmt.query(&[&&[1i32, 3, 4][..]]).unwrap(); assert_eq!( @@ -382,7 +383,8 @@ fn test_slice_wrong_type() { conn.simple_query("CREATE TEMPORARY TABLE foo (id SERIAL PRIMARY KEY)") .unwrap(); - let stmt = conn.prepare("SELECT * FROM foo WHERE id = ANY($1)") + let stmt = conn + .prepare("SELECT * FROM foo WHERE id = ANY($1)") .unwrap(); let err = stmt.query(&[&&["hi"][..]]).unwrap_err(); match err.as_conversion() { diff --git a/postgres/tests/types/uuid.rs b/postgres/tests/types/uuid.rs index fd03ca82..d1b995ad 100644 --- a/postgres/tests/types/uuid.rs +++ b/postgres/tests/types/uuid.rs @@ -8,9 +8,7 @@ fn test_uuid_params() { "UUID", &[ ( - Some( - uuid::Uuid::parse_str("a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11").unwrap(), - ), + Some(uuid::Uuid::parse_str("a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11").unwrap()), "'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'", ), (None, "NULL"), diff --git a/tokio-postgres/src/error/sqlstate.rs b/tokio-postgres/src/error/sqlstate.rs index c8e3ec2e..7dddfc7e 100644 --- a/tokio-postgres/src/error/sqlstate.rs +++ b/tokio-postgres/src/error/sqlstate.rs @@ -33,7 +33,8 @@ impl SqlState { pub const WARNING_IMPLICIT_ZERO_BIT_PADDING: SqlState = SqlState(Cow::Borrowed("01008")); /// 01003 - pub const WARNING_NULL_VALUE_ELIMINATED_IN_SET_FUNCTION: SqlState = SqlState(Cow::Borrowed("01003")); + pub const WARNING_NULL_VALUE_ELIMINATED_IN_SET_FUNCTION: SqlState = + SqlState(Cow::Borrowed("01003")); /// 01007 pub const WARNING_PRIVILEGE_NOT_GRANTED: SqlState = SqlState(Cow::Borrowed("01007")); @@ -51,7 +52,8 @@ impl SqlState { pub const NO_DATA: SqlState = SqlState(Cow::Borrowed("02000")); /// 02001 - pub const NO_ADDITIONAL_DYNAMIC_RESULT_SETS_RETURNED: SqlState = SqlState(Cow::Borrowed("02001")); + pub const NO_ADDITIONAL_DYNAMIC_RESULT_SETS_RETURNED: SqlState = + SqlState(Cow::Borrowed("02001")); /// 03000 pub const SQL_STATEMENT_NOT_YET_COMPLETE: SqlState = SqlState(Cow::Borrowed("03000")); @@ -66,10 +68,12 @@ impl SqlState { pub const CONNECTION_FAILURE: SqlState = SqlState(Cow::Borrowed("08006")); /// 08001 - pub const SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION: SqlState = SqlState(Cow::Borrowed("08001")); + pub const SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION: SqlState = + SqlState(Cow::Borrowed("08001")); /// 08004 - pub const SQLSERVER_REJECTED_ESTABLISHMENT_OF_SQLCONNECTION: SqlState = SqlState(Cow::Borrowed("08004")); + pub const SQLSERVER_REJECTED_ESTABLISHMENT_OF_SQLCONNECTION: SqlState = + SqlState(Cow::Borrowed("08004")); /// 08007 pub const TRANSACTION_RESOLUTION_UNKNOWN: SqlState = SqlState(Cow::Borrowed("08007")); @@ -105,7 +109,8 @@ impl SqlState { pub const DIAGNOSTICS_EXCEPTION: SqlState = SqlState(Cow::Borrowed("0Z000")); /// 0Z002 - pub const STACKED_DIAGNOSTICS_ACCESSED_WITHOUT_ACTIVE_HANDLER: SqlState = SqlState(Cow::Borrowed("0Z002")); + pub const STACKED_DIAGNOSTICS_ACCESSED_WITHOUT_ACTIVE_HANDLER: SqlState = + SqlState(Cow::Borrowed("0Z002")); /// 20000 pub const CASE_NOT_FOUND: SqlState = SqlState(Cow::Borrowed("20000")); @@ -159,7 +164,8 @@ impl SqlState { pub const INVALID_ARGUMENT_FOR_POWER_FUNCTION: SqlState = SqlState(Cow::Borrowed("2201F")); /// 2201G - pub const INVALID_ARGUMENT_FOR_WIDTH_BUCKET_FUNCTION: SqlState = SqlState(Cow::Borrowed("2201G")); + pub const INVALID_ARGUMENT_FOR_WIDTH_BUCKET_FUNCTION: SqlState = + SqlState(Cow::Borrowed("2201G")); /// 22018 pub const INVALID_CHARACTER_VALUE_FOR_CAST: SqlState = SqlState(Cow::Borrowed("22018")); @@ -192,7 +198,8 @@ impl SqlState { pub const INVALID_ROW_COUNT_IN_LIMIT_CLAUSE: SqlState = SqlState(Cow::Borrowed("2201W")); /// 2201X - pub const INVALID_ROW_COUNT_IN_RESULT_OFFSET_CLAUSE: SqlState = SqlState(Cow::Borrowed("2201X")); + pub const INVALID_ROW_COUNT_IN_RESULT_OFFSET_CLAUSE: SqlState = + SqlState(Cow::Borrowed("2201X")); /// 2202H pub const INVALID_TABLESAMPLE_ARGUMENT: SqlState = SqlState(Cow::Borrowed("2202H")); @@ -303,22 +310,27 @@ impl SqlState { pub const BRANCH_TRANSACTION_ALREADY_ACTIVE: SqlState = SqlState(Cow::Borrowed("25002")); /// 25008 - pub const HELD_CURSOR_REQUIRES_SAME_ISOLATION_LEVEL: SqlState = SqlState(Cow::Borrowed("25008")); + pub const HELD_CURSOR_REQUIRES_SAME_ISOLATION_LEVEL: SqlState = + SqlState(Cow::Borrowed("25008")); /// 25003 - pub const INAPPROPRIATE_ACCESS_MODE_FOR_BRANCH_TRANSACTION: SqlState = SqlState(Cow::Borrowed("25003")); + pub const INAPPROPRIATE_ACCESS_MODE_FOR_BRANCH_TRANSACTION: SqlState = + SqlState(Cow::Borrowed("25003")); /// 25004 - pub const INAPPROPRIATE_ISOLATION_LEVEL_FOR_BRANCH_TRANSACTION: SqlState = SqlState(Cow::Borrowed("25004")); + pub const INAPPROPRIATE_ISOLATION_LEVEL_FOR_BRANCH_TRANSACTION: SqlState = + SqlState(Cow::Borrowed("25004")); /// 25005 - pub const NO_ACTIVE_SQL_TRANSACTION_FOR_BRANCH_TRANSACTION: SqlState = SqlState(Cow::Borrowed("25005")); + pub const NO_ACTIVE_SQL_TRANSACTION_FOR_BRANCH_TRANSACTION: SqlState = + SqlState(Cow::Borrowed("25005")); /// 25006 pub const READ_ONLY_SQL_TRANSACTION: SqlState = SqlState(Cow::Borrowed("25006")); /// 25007 - pub const SCHEMA_AND_DATA_STATEMENT_MIXING_NOT_SUPPORTED: SqlState = SqlState(Cow::Borrowed("25007")); + pub const SCHEMA_AND_DATA_STATEMENT_MIXING_NOT_SUPPORTED: SqlState = + SqlState(Cow::Borrowed("25007")); /// 25P01 pub const NO_ACTIVE_SQL_TRANSACTION: SqlState = SqlState(Cow::Borrowed("25P01")); @@ -345,7 +357,8 @@ impl SqlState { pub const INVALID_PASSWORD: SqlState = SqlState(Cow::Borrowed("28P01")); /// 2B000 - pub const DEPENDENT_PRIVILEGE_DESCRIPTORS_STILL_EXIST: SqlState = SqlState(Cow::Borrowed("2B000")); + pub const DEPENDENT_PRIVILEGE_DESCRIPTORS_STILL_EXIST: SqlState = + SqlState(Cow::Borrowed("2B000")); /// 2BP01 pub const DEPENDENT_OBJECTS_STILL_EXIST: SqlState = SqlState(Cow::Borrowed("2BP01")); @@ -357,7 +370,8 @@ impl SqlState { pub const SQL_ROUTINE_EXCEPTION: SqlState = SqlState(Cow::Borrowed("2F000")); /// 2F005 - pub const S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT: SqlState = SqlState(Cow::Borrowed("2F005")); + pub const S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT: SqlState = + SqlState(Cow::Borrowed("2F005")); /// 2F002 pub const S_R_E_MODIFYING_SQL_DATA_NOT_PERMITTED: SqlState = SqlState(Cow::Borrowed("2F002")); @@ -699,7 +713,8 @@ impl SqlState { pub const FDW_INVALID_OPTION_NAME: SqlState = SqlState(Cow::Borrowed("HV00D")); /// HV090 - pub const FDW_INVALID_STRING_LENGTH_OR_BUFFER_LENGTH: SqlState = SqlState(Cow::Borrowed("HV090")); + pub const FDW_INVALID_STRING_LENGTH_OR_BUFFER_LENGTH: SqlState = + SqlState(Cow::Borrowed("HV090")); /// HV00A pub const FDW_INVALID_STRING_FORMAT: SqlState = SqlState(Cow::Borrowed("HV00A"));