From b8cd2e9388fd150d4846cae36acffa4614daa6ec Mon Sep 17 00:00:00 2001 From: Ryan Leckey Date: Mon, 2 Mar 2020 00:21:52 -0800 Subject: [PATCH] remove unused imports --- sqlx-core/src/connection.rs | 4 -- sqlx-core/src/cursor.rs | 4 -- sqlx-core/src/database.rs | 3 +- sqlx-core/src/decode.rs | 5 +- sqlx-core/src/executor.rs | 5 +- sqlx-core/src/io/buf_stream.rs | 6 --- sqlx-core/src/lib.rs | 1 - sqlx-core/src/pool/connection.rs | 2 - sqlx-core/src/pool/executor.rs | 7 +-- sqlx-core/src/pool/mod.rs | 1 - sqlx-core/src/postgres/connection.rs | 13 ++--- sqlx-core/src/postgres/cursor.rs | 15 +----- sqlx-core/src/postgres/executor.rs | 9 +--- .../src/postgres/protocol/authentication.rs | 21 +------- sqlx-core/src/postgres/protocol/close.rs | 51 ------------------- .../src/postgres/protocol/command_complete.rs | 1 - sqlx-core/src/postgres/protocol/data_row.rs | 5 +- sqlx-core/src/postgres/protocol/message.rs | 5 -- sqlx-core/src/postgres/protocol/mod.rs | 3 -- .../protocol/parameter_description.rs | 2 +- sqlx-core/src/postgres/protocol/response.rs | 1 - .../src/postgres/protocol/row_description.rs | 2 +- sqlx-core/src/postgres/row.rs | 6 +-- sqlx-core/src/postgres/sasl.rs | 4 +- sqlx-core/src/postgres/stream.rs | 11 ++-- sqlx-core/src/postgres/tls.rs | 3 -- sqlx-core/src/postgres/types/bytes.rs | 6 +-- sqlx-core/src/postgres/types/int.rs | 2 +- sqlx-core/src/query.rs | 13 +---- sqlx-core/src/query_as.rs | 20 +++----- 30 files changed, 35 insertions(+), 196 deletions(-) delete mode 100644 sqlx-core/src/postgres/protocol/close.rs diff --git a/sqlx-core/src/connection.rs b/sqlx-core/src/connection.rs index b7beb5ff..3e48ff5d 100644 --- a/sqlx-core/src/connection.rs +++ b/sqlx-core/src/connection.rs @@ -1,11 +1,7 @@ use std::convert::TryInto; -use std::ops::{Deref, DerefMut}; use futures_core::future::BoxFuture; -use futures_util::TryFutureExt; -use crate::database::Database; -use crate::describe::Describe; use crate::executor::Executor; use crate::pool::{Pool, PoolConnection}; use crate::url::Url; diff --git a/sqlx-core/src/cursor.rs b/sqlx-core/src/cursor.rs index ae033cd0..caf690fd 100644 --- a/sqlx-core/src/cursor.rs +++ b/sqlx-core/src/cursor.rs @@ -1,13 +1,9 @@ -use std::future::Future; - use futures_core::future::BoxFuture; -use futures_core::stream::BoxStream; use crate::connection::{Connect, MaybeOwnedConnection}; use crate::database::{Database, HasRow}; use crate::executor::Execute; use crate::pool::Pool; -use crate::row::Row; /// Represents a result set, which is generated by executing a query against the database. /// diff --git a/sqlx-core/src/database.rs b/sqlx-core/src/database.rs index 5db505f7..79c67445 100644 --- a/sqlx-core/src/database.rs +++ b/sqlx-core/src/database.rs @@ -1,9 +1,8 @@ use std::fmt::Display; use crate::arguments::Arguments; -use crate::connection::{Connect, Connection}; +use crate::connection::Connect; use crate::cursor::Cursor; -use crate::query_as::QueryAs; use crate::row::Row; use crate::types::TypeInfo; diff --git a/sqlx-core/src/decode.rs b/sqlx-core/src/decode.rs index 02e286d5..32774a28 100644 --- a/sqlx-core/src/decode.rs +++ b/sqlx-core/src/decode.rs @@ -1,9 +1,6 @@ //! Types and traits for decoding values from the database. -use std::error::Error as StdError; -use std::fmt::{self, Display}; - -use crate::database::{Database, HasRawValue}; +use crate::database::HasRawValue; /// Decode a single value from the database. pub trait Decode<'de, DB> diff --git a/sqlx-core/src/executor.rs b/sqlx-core/src/executor.rs index 0995170a..8c3dc8d7 100644 --- a/sqlx-core/src/executor.rs +++ b/sqlx-core/src/executor.rs @@ -1,8 +1,7 @@ +use futures_core::future::BoxFuture; + use crate::database::{Database, HasCursor}; use crate::describe::Describe; -use futures_core::future::BoxFuture; -use futures_core::stream::BoxStream; -use futures_util::TryStreamExt; /// A type that contains or can provide a database connection to use for executing queries /// against the database. diff --git a/sqlx-core/src/io/buf_stream.rs b/sqlx-core/src/io/buf_stream.rs index 1d002fa1..c3750a15 100644 --- a/sqlx-core/src/io/buf_stream.rs +++ b/sqlx-core/src/io/buf_stream.rs @@ -55,12 +55,6 @@ where Ok(()) } - pub fn clear_bufs(&mut self) { - self.rbuf_rindex = 0; - self.rbuf_windex = 0; - self.wbuf.clear(); - } - #[inline] pub fn consume(&mut self, cnt: usize) { self.rbuf_rindex += cnt; diff --git a/sqlx-core/src/lib.rs b/sqlx-core/src/lib.rs index 320f2ecf..c0c77ad5 100644 --- a/sqlx-core/src/lib.rs +++ b/sqlx-core/src/lib.rs @@ -1,7 +1,6 @@ //! Core of SQLx, the rust SQL toolkit. Not intended to be used directly. #![forbid(unsafe_code)] -#![allow(unused)] #![cfg_attr(docsrs, feature(doc_cfg))] #[macro_use] diff --git a/sqlx-core/src/pool/connection.rs b/sqlx-core/src/pool/connection.rs index a32def7c..a45a9ca7 100644 --- a/sqlx-core/src/pool/connection.rs +++ b/sqlx-core/src/pool/connection.rs @@ -5,8 +5,6 @@ use std::time::Instant; use super::inner::{DecrementSizeGuard, SharedPool}; use crate::connection::{Connect, Connection}; -use crate::describe::Describe; -use crate::executor::Executor; /// A connection checked out from [`Pool`][crate::Pool]. /// diff --git a/sqlx-core/src/pool/executor.rs b/sqlx-core/src/pool/executor.rs index c49765bc..705953af 100644 --- a/sqlx-core/src/pool/executor.rs +++ b/sqlx-core/src/pool/executor.rs @@ -1,10 +1,7 @@ -use std::ops::DerefMut; - -use futures_core::{future::BoxFuture, stream::BoxStream}; -use futures_util::StreamExt; +use futures_core::future::BoxFuture; use super::PoolConnection; -use crate::connection::{Connect, Connection}; +use crate::connection::Connect; use crate::cursor::Cursor; use crate::database::{Database, HasCursor}; use crate::describe::Describe; diff --git a/sqlx-core/src/pool/mod.rs b/sqlx-core/src/pool/mod.rs index 6bf543e6..5551fa9a 100644 --- a/sqlx-core/src/pool/mod.rs +++ b/sqlx-core/src/pool/mod.rs @@ -7,7 +7,6 @@ use std::{ }; use crate::connection::Connect; -use crate::database::Database; use crate::transaction::Transaction; use self::inner::SharedPool; diff --git a/sqlx-core/src/postgres/connection.rs b/sqlx-core/src/postgres/connection.rs index bd45128c..791937d5 100644 --- a/sqlx-core/src/postgres/connection.rs +++ b/sqlx-core/src/postgres/connection.rs @@ -1,27 +1,20 @@ -use std::borrow::Cow; use std::collections::HashMap; use std::convert::TryInto; use std::ops::Range; use std::sync::Arc; -use byteorder::NetworkEndian; use futures_core::future::BoxFuture; -use futures_core::Future; use futures_util::TryFutureExt; use crate::connection::{Connect, Connection}; -use crate::describe::{Column, Describe}; use crate::executor::Executor; -use crate::io::{Buf, BufStream, MaybeTlsStream}; use crate::postgres::protocol::{ - self, Authentication, AuthenticationMd5, AuthenticationSasl, Decode, Encode, Message, - ParameterDescription, PasswordMessage, RowDescription, StartupMessage, StatementId, Terminate, - TypeFormat, + Authentication, AuthenticationMd5, AuthenticationSasl, Message, PasswordMessage, + StartupMessage, StatementId, Terminate, TypeFormat, }; use crate::postgres::stream::PgStream; -use crate::postgres::{sasl, tls, PgError, PgTypeInfo, Postgres}; +use crate::postgres::{sasl, tls}; use crate::url::Url; -use crate::Error; /// An asynchronous connection to a [Postgres][super::Postgres] database. /// diff --git a/sqlx-core/src/postgres/cursor.rs b/sqlx-core/src/postgres/cursor.rs index 47891558..7ca028ee 100644 --- a/sqlx-core/src/postgres/cursor.rs +++ b/sqlx-core/src/postgres/cursor.rs @@ -1,25 +1,14 @@ use std::collections::HashMap; -use std::future::Future; -use std::mem; -use std::pin::Pin; use std::sync::Arc; -use std::task::{Context, Poll}; -use async_stream::try_stream; use futures_core::future::BoxFuture; -use futures_core::stream::BoxStream; use crate::connection::{ConnectionSource, MaybeOwnedConnection}; use crate::cursor::Cursor; -use crate::database::Database; -use crate::database::HasRow; use crate::executor::Execute; -use crate::pool::{Pool, PoolConnection}; -use crate::postgres::protocol::{ - CommandComplete, DataRow, Message, RowDescription, StatementId, TypeFormat, -}; +use crate::pool::Pool; +use crate::postgres::protocol::{DataRow, Message, RowDescription, StatementId, TypeFormat}; use crate::postgres::{PgArguments, PgConnection, PgRow, Postgres}; -use futures_core::Stream; pub struct PgCursor<'c, 'q> { source: ConnectionSource<'c, PgConnection>, diff --git a/sqlx-core/src/postgres/executor.rs b/sqlx-core/src/postgres/executor.rs index 7a97c3ab..22018786 100644 --- a/sqlx-core/src/postgres/executor.rs +++ b/sqlx-core/src/postgres/executor.rs @@ -1,17 +1,12 @@ -use std::collections::HashMap; -use std::io; -use std::sync::Arc; - use futures_core::future::BoxFuture; use crate::cursor::Cursor; use crate::describe::{Column, Describe}; use crate::executor::{Execute, Executor, RefExecutor}; use crate::postgres::protocol::{ - self, CommandComplete, Encode, Message, ParameterDescription, RowDescription, StatementId, - TypeFormat, + self, CommandComplete, Message, ParameterDescription, RowDescription, StatementId, TypeFormat, }; -use crate::postgres::{PgArguments, PgConnection, PgCursor, PgRow, PgTypeInfo, Postgres}; +use crate::postgres::{PgArguments, PgConnection, PgCursor, PgTypeInfo, Postgres}; impl PgConnection { pub(crate) fn write_simple_query(&mut self, query: &str) { diff --git a/sqlx-core/src/postgres/protocol/authentication.rs b/sqlx-core/src/postgres/protocol/authentication.rs index 869e5098..2edb1541 100644 --- a/sqlx-core/src/postgres/protocol/authentication.rs +++ b/sqlx-core/src/postgres/protocol/authentication.rs @@ -1,5 +1,4 @@ use crate::io::Buf; -use crate::postgres::protocol::Decode; use byteorder::NetworkEndian; use std::str; @@ -82,7 +81,7 @@ pub struct AuthenticationMd5 { } impl AuthenticationMd5 { - pub fn read(mut buf: &[u8]) -> crate::Result { + pub fn read(buf: &[u8]) -> crate::Result { let mut salt = [0_u8; 4]; salt.copy_from_slice(buf); @@ -118,7 +117,7 @@ pub struct AuthenticationSaslContinue { } impl AuthenticationSaslContinue { - pub fn read(mut buf: &[u8]) -> crate::Result { + pub fn read(buf: &[u8]) -> crate::Result { let mut salt: Vec = Vec::new(); let mut nonce: Vec = Vec::new(); let mut iter_count: u32 = 0; @@ -163,22 +162,6 @@ impl AuthenticationSaslContinue { } } -#[derive(Debug)] -pub struct AuthenticationSaslFinal { - pub data: Box<[u8]>, -} - -impl AuthenticationSaslFinal { - pub fn read(mut buf: &[u8]) -> crate::Result { - let mut data = Vec::with_capacity(buf.len()); - data.extend_from_slice(buf); - - Ok(Self { - data: data.into_boxed_slice(), - }) - } -} - #[cfg(test)] mod tests { use super::{Authentication, Decode}; diff --git a/sqlx-core/src/postgres/protocol/close.rs b/sqlx-core/src/postgres/protocol/close.rs deleted file mode 100644 index 73588f01..00000000 --- a/sqlx-core/src/postgres/protocol/close.rs +++ /dev/null @@ -1,51 +0,0 @@ -#![allow(dead_code)] -use crate::io::BufMut; -use crate::postgres::protocol::Encode; -use byteorder::NetworkEndian; - -pub enum Close<'a> { - Statement(&'a str), - Portal(&'a str), -} - -impl Encode for Close<'_> { - fn encode(&self, buf: &mut Vec) { - buf.push(b'C'); - - let (kind, name) = match self { - Close::Statement(name) => (b'S', name), - Close::Portal(name) => (b'P', name), - }; - - // len + kind + nul + len(string) - buf.put_i32::((4 + 1 + 1 + name.len()) as i32); - - buf.push(kind); - buf.put_str_nul(name); - } -} - -#[cfg(test)] -mod test { - use super::{Close, Encode}; - - #[test] - fn it_encodes_close_portal() { - let mut buf = Vec::new(); - let m = Close::Portal("__sqlx_p_1"); - - m.encode(&mut buf); - - assert_eq!(buf, b"C\0\0\0\x10P__sqlx_p_1\0"); - } - - #[test] - fn it_encodes_close_statement() { - let mut buf = Vec::new(); - let m = Close::Statement("__sqlx_s_1"); - - m.encode(&mut buf); - - assert_eq!(buf, b"C\0\0\0\x10S__sqlx_s_1\0"); - } -} diff --git a/sqlx-core/src/postgres/protocol/command_complete.rs b/sqlx-core/src/postgres/protocol/command_complete.rs index 56695787..46efc659 100644 --- a/sqlx-core/src/postgres/protocol/command_complete.rs +++ b/sqlx-core/src/postgres/protocol/command_complete.rs @@ -1,5 +1,4 @@ use crate::io::Buf; -use crate::postgres::protocol::Decode; #[derive(Debug)] pub struct CommandComplete { diff --git a/sqlx-core/src/postgres/protocol/data_row.rs b/sqlx-core/src/postgres/protocol/data_row.rs index 0c9c034c..53f505b5 100644 --- a/sqlx-core/src/postgres/protocol/data_row.rs +++ b/sqlx-core/src/postgres/protocol/data_row.rs @@ -1,8 +1,5 @@ -use crate::io::{Buf, ByteStr}; -use crate::postgres::protocol::Decode; -use crate::postgres::PgConnection; +use crate::io::Buf; use byteorder::NetworkEndian; -use std::fmt::{self, Debug}; use std::ops::Range; pub struct DataRow<'c> { diff --git a/sqlx-core/src/postgres/protocol/message.rs b/sqlx-core/src/postgres/protocol/message.rs index 16f9f86f..95aa98db 100644 --- a/sqlx-core/src/postgres/protocol/message.rs +++ b/sqlx-core/src/postgres/protocol/message.rs @@ -1,10 +1,5 @@ use std::convert::TryFrom; -use crate::postgres::protocol::{ - Authentication, BackendKeyData, CommandComplete, DataRow, NotificationResponse, - ParameterDescription, ParameterStatus, ReadyForQuery, Response, RowDescription, -}; - #[derive(Debug, Copy, Clone)] #[repr(u8)] pub enum Message { diff --git a/sqlx-core/src/postgres/protocol/mod.rs b/sqlx-core/src/postgres/protocol/mod.rs index 24b98f41..332e6de0 100644 --- a/sqlx-core/src/postgres/protocol/mod.rs +++ b/sqlx-core/src/postgres/protocol/mod.rs @@ -10,7 +10,6 @@ pub use type_id::TypeId; // REQUESTS mod bind; mod cancel_request; -mod close; mod describe; mod encode; mod execute; @@ -28,7 +27,6 @@ mod terminate; pub use bind::Bind; pub use cancel_request::CancelRequest; -pub use close::Close; pub use describe::Describe; pub use encode::Encode; pub use execute::Execute; @@ -60,7 +58,6 @@ mod message; pub use authentication::{ Authentication, AuthenticationMd5, AuthenticationSasl, AuthenticationSaslContinue, - AuthenticationSaslFinal, }; pub use backend_key_data::BackendKeyData; pub use command_complete::CommandComplete; diff --git a/sqlx-core/src/postgres/protocol/parameter_description.rs b/sqlx-core/src/postgres/protocol/parameter_description.rs index 1dd9c119..6e3db849 100644 --- a/sqlx-core/src/postgres/protocol/parameter_description.rs +++ b/sqlx-core/src/postgres/protocol/parameter_description.rs @@ -1,5 +1,5 @@ use crate::io::Buf; -use crate::postgres::protocol::{Decode, TypeId}; +use crate::postgres::protocol::TypeId; use byteorder::NetworkEndian; #[derive(Debug)] diff --git a/sqlx-core/src/postgres/protocol/response.rs b/sqlx-core/src/postgres/protocol/response.rs index 5afbbc0b..9c36033a 100644 --- a/sqlx-core/src/postgres/protocol/response.rs +++ b/sqlx-core/src/postgres/protocol/response.rs @@ -1,5 +1,4 @@ use crate::io::Buf; -use crate::postgres::protocol::Decode; use std::str::{self, FromStr}; #[derive(Debug, Copy, Clone)] diff --git a/sqlx-core/src/postgres/protocol/row_description.rs b/sqlx-core/src/postgres/protocol/row_description.rs index eb9b8aef..15ca2315 100644 --- a/sqlx-core/src/postgres/protocol/row_description.rs +++ b/sqlx-core/src/postgres/protocol/row_description.rs @@ -1,5 +1,5 @@ use crate::io::Buf; -use crate::postgres::protocol::{Decode, TypeFormat, TypeId}; +use crate::postgres::protocol::{TypeFormat, TypeId}; use byteorder::NetworkEndian; #[derive(Debug)] diff --git a/sqlx-core/src/postgres/row.rs b/sqlx-core/src/postgres/row.rs index fcba6c64..26ce02fd 100644 --- a/sqlx-core/src/postgres/row.rs +++ b/sqlx-core/src/postgres/row.rs @@ -4,14 +4,10 @@ use std::collections::HashMap; use std::convert::TryFrom; use std::sync::Arc; -use crate::connection::MaybeOwnedConnection; -use crate::decode::Decode; use crate::error::UnexpectedNullError; -use crate::pool::PoolConnection; use crate::postgres::protocol::{DataRow, TypeFormat}; -use crate::postgres::{PgConnection, Postgres}; +use crate::postgres::Postgres; use crate::row::{ColumnIndex, Row}; -use crate::types::Type; /// A value from Postgres. This may be in a BINARY or TEXT format depending /// on the data type and if the query was prepared or not. diff --git a/sqlx-core/src/postgres/sasl.rs b/sqlx-core/src/postgres/sasl.rs index 73df9157..79881b56 100644 --- a/sqlx-core/src/postgres/sasl.rs +++ b/sqlx-core/src/postgres/sasl.rs @@ -3,11 +3,9 @@ use rand::Rng; use sha2::{Digest, Sha256}; use crate::postgres::protocol::{ - hi, Authentication, AuthenticationSaslContinue, Encode, Message, SaslInitialResponse, - SaslResponse, + hi, Authentication, AuthenticationSaslContinue, Message, SaslInitialResponse, SaslResponse, }; use crate::postgres::stream::PgStream; -use crate::postgres::PgConnection; static GS2_HEADER: &'static str = "n,,"; static CHANNEL_ATTR: &'static str = "c"; diff --git a/sqlx-core/src/postgres/stream.rs b/sqlx-core/src/postgres/stream.rs index b1c4f111..0b19ad02 100644 --- a/sqlx-core/src/postgres/stream.rs +++ b/sqlx-core/src/postgres/stream.rs @@ -4,7 +4,7 @@ use std::net::Shutdown; use byteorder::NetworkEndian; use crate::io::{Buf, BufStream, MaybeTlsStream}; -use crate::postgres::protocol::{Encode, Message, Response, Severity}; +use crate::postgres::protocol::{Encode, Message, Response}; use crate::postgres::PgError; use crate::url::Url; @@ -73,13 +73,10 @@ impl PgStream { match type_ { Message::ErrorResponse | Message::NoticeResponse => { let response = Response::read(self.stream.buffer())?; - match response.severity { - Severity::Error | Severity::Panic | Severity::Fatal => { - // This is an error, bubble up as one immediately - return Err(crate::Error::Database(Box::new(PgError(response)))); - } - _ => {} + if response.severity.is_error() { + // This is an error, bubble up as one immediately + return Err(crate::Error::Database(Box::new(PgError(response)))); } // TODO: Provide some way of receiving these non-critical diff --git a/sqlx-core/src/postgres/tls.rs b/sqlx-core/src/postgres/tls.rs index 2b91675e..94112048 100644 --- a/sqlx-core/src/postgres/tls.rs +++ b/sqlx-core/src/postgres/tls.rs @@ -1,9 +1,6 @@ use crate::postgres::protocol::SslRequest; use crate::postgres::stream::PgStream; -use crate::postgres::PgConnection; use crate::url::Url; -use std::borrow::Cow; -use std::fs::read; pub(crate) async fn request_if_needed(stream: &mut PgStream, url: &Url) -> crate::Result<()> { // https://www.postgresql.org/docs/12/libpq-ssl.html#LIBPQ-SSL-SSLMODE-STATEMENTS diff --git a/sqlx-core/src/postgres/types/bytes.rs b/sqlx-core/src/postgres/types/bytes.rs index c7f3334c..e85b8c26 100644 --- a/sqlx-core/src/postgres/types/bytes.rs +++ b/sqlx-core/src/postgres/types/bytes.rs @@ -40,7 +40,7 @@ impl Encode for Vec { impl<'de> Decode<'de, Postgres> for Vec { fn decode(value: Option>) -> crate::Result { match value.try_into()? { - PgValue::Binary(mut buf) => Ok(buf.to_vec()), + PgValue::Binary(buf) => Ok(buf.to_vec()), PgValue::Text(s) => { // BYTEA is formatted as \x followed by hex characters hex::decode(&s[2..]).map_err(crate::Error::decode) @@ -52,8 +52,8 @@ impl<'de> Decode<'de, Postgres> for Vec { impl<'de> Decode<'de, Postgres> for &'de [u8] { fn decode(value: Option>) -> crate::Result { match value.try_into()? { - PgValue::Binary(mut buf) => Ok(buf), - PgValue::Text(s) => Err(crate::Error::Decode( + PgValue::Binary(buf) => Ok(buf), + PgValue::Text(_s) => Err(crate::Error::Decode( "unsupported decode to `&[u8]` of BYTEA in a simple query; \ use a prepared query or decode to `Vec`" .into(), diff --git a/sqlx-core/src/postgres/types/int.rs b/sqlx-core/src/postgres/types/int.rs index c4e371d3..8f0eace7 100644 --- a/sqlx-core/src/postgres/types/int.rs +++ b/sqlx-core/src/postgres/types/int.rs @@ -1,7 +1,7 @@ use std::convert::TryInto; use std::str::FromStr; -use byteorder::{ByteOrder, NetworkEndian, ReadBytesExt}; +use byteorder::{NetworkEndian, ReadBytesExt}; use crate::decode::Decode; use crate::encode::Encode; diff --git a/sqlx-core/src/query.rs b/sqlx-core/src/query.rs index f7c99f92..a9dd25dd 100644 --- a/sqlx-core/src/query.rs +++ b/sqlx-core/src/query.rs @@ -1,27 +1,16 @@ -use std::future::Future; use std::marker::PhantomData; -use std::mem; -use std::pin::Pin; -use std::task::{Context, Poll}; use async_stream::try_stream; -use futures_core::future::BoxFuture; -use futures_core::stream::BoxStream; use futures_core::Stream; use futures_util::future::ready; -use futures_util::ready; -use futures_util::stream::try_unfold; use futures_util::TryFutureExt; -use futures_util::TryStreamExt; use crate::arguments::Arguments; use crate::cursor::Cursor; use crate::database::{Database, HasCursor, HasRow}; use crate::encode::Encode; use crate::executor::{Execute, Executor, RefExecutor}; -use crate::row::FromRow; use crate::types::Type; -use crate::Error; /// Raw SQL query with bind parameters. Returned by [`query`][crate::query::query]. pub struct Query<'q, DB, A = ::Arguments> @@ -163,7 +152,7 @@ where } /// Get the first row in the result - pub async fn fetch_optional<'e, E>(mut self, executor: E) -> crate::Result> + pub async fn fetch_optional<'e, E>(self, executor: E) -> crate::Result> where E: RefExecutor<'e, Database = DB>, 'q: 'e, diff --git a/sqlx-core/src/query_as.rs b/sqlx-core/src/query_as.rs index 59ffd153..73f979ae 100644 --- a/sqlx-core/src/query_as.rs +++ b/sqlx-core/src/query_as.rs @@ -1,17 +1,9 @@ use core::marker::PhantomData; -use async_stream::try_stream; -use futures_core::future::BoxFuture; -use futures_core::stream::Stream; -use futures_util::future::ready; -use futures_util::future::TryFutureExt; - use crate::arguments::Arguments; -use crate::cursor::Cursor; -use crate::database::{Database, HasRow}; +use crate::database::Database; use crate::encode::Encode; -use crate::executor::{Execute, RefExecutor}; -use crate::row::FromRow; +use crate::executor::Execute; use crate::types::Type; /// Raw SQL query with bind parameters, mapped to a concrete type @@ -118,7 +110,7 @@ macro_rules! make_query_as { impl<'q, O> $name<'q, O> for crate::query_as::QueryAs<'q, $db, O> { fn fetch<'e, E>( - mut self, + self, executor: E, ) -> futures_core::stream::BoxStream<'e, crate::Result> where @@ -140,7 +132,7 @@ macro_rules! make_query_as { } fn fetch_optional<'e, E>( - mut self, + self, executor: E, ) -> futures_core::future::BoxFuture<'e, crate::Result>> where @@ -159,7 +151,7 @@ macro_rules! make_query_as { } fn fetch_one<'e, E>( - mut self, + self, executor: E, ) -> futures_core::future::BoxFuture<'e, crate::Result> where @@ -176,7 +168,7 @@ macro_rules! make_query_as { } fn fetch_all<'e, E>( - mut self, + self, executor: E, ) -> futures_core::future::BoxFuture<'e, crate::Result>> where