From fd52ed2891d40d8546fc02dcc7153eb4a48f51e3 Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Wed, 1 Jun 2022 17:00:44 -0400 Subject: [PATCH] Relax prep() to take impl AsQuery This was missed in the refactor of everything else to use AsQuery instead of `AsRef + Send + Sync` --- src/queryable/mod.rs | 8 ++++---- src/queryable/stmt.rs | 45 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/src/queryable/mod.rs b/src/queryable/mod.rs index 2b7ef69d..b6bcc2b6 100644 --- a/src/queryable/mod.rs +++ b/src/queryable/mod.rs @@ -135,7 +135,7 @@ pub trait Queryable: Send { /// [stmt_cache_size]: crate::Opts::stmt_cache_size fn prep<'a, Q>(&'a mut self, query: Q) -> BoxFuture<'a, Statement> where - Q: AsRef + Sync + Send + 'a; + Q: AsQuery + 'a; /// Closes the given statement. /// @@ -464,9 +464,9 @@ impl Queryable for Conn { fn prep<'a, Q>(&'a mut self, query: Q) -> BoxFuture<'a, Statement> where - Q: AsRef + Sync + Send + 'a, + Q: AsQuery + 'a, { - async move { self.get_statement(query.as_ref()).await }.boxed() + async move { self.get_statement(query.as_query()).await }.boxed() } fn close(&mut self, stmt: Statement) -> BoxFuture<'_, ()> { @@ -533,7 +533,7 @@ impl Queryable for Transaction<'_> { fn prep<'a, Q>(&'a mut self, query: Q) -> BoxFuture<'a, Statement> where - Q: AsRef + Sync + Send + 'a, + Q: AsQuery + 'a, { self.0.prep(query) } diff --git a/src/queryable/stmt.rs b/src/queryable/stmt.rs index 99f7f3ea..6b4a2eb8 100644 --- a/src/queryable/stmt.rs +++ b/src/queryable/stmt.rs @@ -101,6 +101,51 @@ impl StatementLike for Arc { } } +impl StatementLike for Cow<'_, [u8]> { + fn to_statement<'a>(self, conn: &'a mut crate::Conn) -> ToStatementResult<'a> + where + Self: 'a, + { + to_statement_move(self, conn) + } +} + +impl StatementLike for &'_ [u8] { + fn to_statement<'a>(self, conn: &'a mut crate::Conn) -> ToStatementResult<'a> + where + Self: 'a, + { + to_statement_move(self, conn) + } +} + +impl StatementLike for Vec { + fn to_statement<'a>(self, conn: &'a mut crate::Conn) -> ToStatementResult<'a> + where + Self: 'a, + { + to_statement_move(self, conn) + } +} + +impl StatementLike for Box<[u8]> { + fn to_statement<'a>(self, conn: &'a mut crate::Conn) -> ToStatementResult<'a> + where + Self: 'a, + { + to_statement_move(self, conn) + } +} + +impl StatementLike for Arc<[u8]> { + fn to_statement<'a>(self, conn: &'a mut crate::Conn) -> ToStatementResult<'a> + where + Self: 'a, + { + to_statement_move(self, conn) + } +} + impl StatementLike for Statement { fn to_statement<'a>(self, _conn: &'a mut crate::Conn) -> ToStatementResult<'static> where