From 609c59e81c1a6a47a81732ec39623791b6411e71 Mon Sep 17 00:00:00 2001 From: Caio Date: Sat, 13 Jan 2024 22:28:17 -0300 Subject: [PATCH] Trim AsyncBounds --- wtx/examples/common/mod.rs | 7 +- wtx/src/client_api_framework/api.rs | 2 +- wtx/src/client_api_framework/dnsn/tests.rs | 13 +- .../client_api_framework/network/transport.rs | 56 ++++----- .../network/transport/bi_transport.rs | 30 ++--- .../network/transport/mock.rs | 24 ++-- .../network/transport/reqwest.rs | 12 +- .../network/transport/std.rs | 41 +++---- .../network/transport/unit.rs | 22 ++-- .../network/transport/wtx.rs | 112 ++++++------------ wtx/src/client_api_framework/pkg.rs | 20 ++-- wtx/src/client_api_framework/pkg/batch_pkg.rs | 20 ++-- .../pkg/pkg_with_helper.rs | 14 +-- wtx/src/database/client/postgres/executor.rs | 18 +-- wtx/src/database/executor.rs | 75 +++++++----- wtx/src/database/from_record.rs | 10 ++ wtx/src/database/from_records.rs | 15 +++ wtx/src/database/orm/crud.rs | 51 +++++--- wtx/src/database/orm/sql_value.rs | 7 ++ wtx/src/database/orm/sql_writer.rs | 53 +++++++++ wtx/src/database/orm/table.rs | 20 ++++ wtx/src/database/orm/table_associations.rs | 9 ++ wtx/src/database/schema_manager.rs | 6 +- .../schema_manager/fixed_sql_commands.rs | 17 +-- .../fixed_sql_commands/postgres.rs | 23 ++-- .../integration_tests/db/postgres.rs | 13 +- wtx/src/misc/stream.rs | 2 +- wtx/src/pool_manager/resource_manager.rs | 17 +++ wtx/src/web_socket/handshake.rs | 8 +- wtx/src/web_socket/handshake/raw.rs | 24 ++-- 30 files changed, 396 insertions(+), 345 deletions(-) diff --git a/wtx/examples/common/mod.rs b/wtx/examples/common/mod.rs index 824bdedf..da000b8b 100644 --- a/wtx/examples/common/mod.rs +++ b/wtx/examples/common/mod.rs @@ -1,5 +1,5 @@ use wtx::{ - misc::{AsyncBounds, Stream}, + misc::Stream, rng::StaticRng, web_socket::{ compression::NegotiatedCompression, @@ -14,9 +14,8 @@ pub(crate) async fn _accept_conn_and_echo_frames( stream: S, ) -> wtx::Result<()> where - C: AsyncBounds + Compression, - C::NegotiatedCompression: AsyncBounds, - S: AsyncBounds + Stream, + C: Compression, + S: Stream, { let mut ws = WebSocketAcceptRaw { compression, diff --git a/wtx/src/client_api_framework/api.rs b/wtx/src/client_api_framework/api.rs index b0917273..78473f4a 100644 --- a/wtx/src/client_api_framework/api.rs +++ b/wtx/src/client_api_framework/api.rs @@ -3,7 +3,7 @@ use core::{fmt::Display, future::Future}; /// Api definitions group different packages into a common namespace and define custom additional /// logical through hooks. -pub trait Api: AsyncBounds { +pub trait Api { /// Any custom error structure that can be constructed from [crate::Error]. type Error: Display + From; diff --git a/wtx/src/client_api_framework/dnsn/tests.rs b/wtx/src/client_api_framework/dnsn/tests.rs index bddcaff4..5ac91f54 100644 --- a/wtx/src/client_api_framework/dnsn/tests.rs +++ b/wtx/src/client_api_framework/dnsn/tests.rs @@ -1,9 +1,6 @@ -use crate::{ - client_api_framework::{ - dnsn::{Deserialize, Serialize}, - pkg::Package, - }, - misc::AsyncBounds, +use crate::client_api_framework::{ + dnsn::{Deserialize, Serialize}, + pkg::Package, }; use alloc::string::String; use core::marker::PhantomData; @@ -21,8 +18,8 @@ impl FooBar { impl Package<(), DRSR, ()> for FooBar where - EREQC: AsyncBounds + Serialize, - ERESC: AsyncBounds + Deserialize, + EREQC: Serialize, + ERESC: Deserialize, { type ExternalRequestContent = EREQC; type ExternalResponseContent = ERESC; diff --git a/wtx/src/client_api_framework/network/transport.rs b/wtx/src/client_api_framework/network/transport.rs index df5a172a..054e0131 100644 --- a/wtx/src/client_api_framework/network/transport.rs +++ b/wtx/src/client_api_framework/network/transport.rs @@ -11,15 +11,12 @@ mod unit; #[cfg(feature = "web-socket")] mod wtx; -use crate::{ - client_api_framework::{ - dnsn::{Deserialize, Serialize}, - misc::log_res, - network::TransportGroup, - pkg::{BatchElems, BatchPkg, Package, PkgsAux}, - Api, Id, - }, - misc::AsyncBounds, +use crate::client_api_framework::{ + dnsn::{Deserialize, Serialize}, + misc::log_res, + network::TransportGroup, + pkg::{BatchElems, BatchPkg, Package, PkgsAux}, + Api, Id, }; pub use bi_transport::*; use cl_aux::DynContigColl; @@ -46,10 +43,10 @@ pub trait Transport { &mut self, pkg: &mut P, pkgs_aux: &mut PkgsAux, - ) -> impl AsyncBounds + Future> + ) -> impl Future> where A: Api, - P: AsyncBounds + Package; + P: Package; /// Sends a request and then awaits its counterpart data response. /// @@ -58,10 +55,10 @@ pub trait Transport { &mut self, pkg: &mut P, pkgs_aux: &mut PkgsAux, - ) -> impl AsyncBounds + Future, A::Error>> + ) -> impl Future, A::Error>> where A: Api, - P: AsyncBounds + Package; + P: Package; /// Convenient method similar to [Self::send_retrieve_and_decode_contained] but used for batch /// requests. @@ -73,18 +70,13 @@ pub trait Transport { pkgs: &mut [P], pkgs_aux: &mut PkgsAux, ress: &mut RESS, - ) -> impl AsyncBounds + Future> + ) -> impl Future> where A: Api, - DRSR: AsyncBounds, - P: AsyncBounds + Package, - P::ExternalRequestContent: AsyncBounds + Borrow + Ord, - P::ExternalResponseContent: AsyncBounds + Borrow + Ord, - RESS: AsyncBounds + DynContigColl, - Self: AsyncBounds, - Self::Params: AsyncBounds, - ::ExternalRequestParams: AsyncBounds, - ::ExternalResponseParams: AsyncBounds, + P: Package, + P::ExternalRequestContent: Borrow + Ord, + P::ExternalResponseContent: Borrow + Ord, + RESS: DynContigColl, for<'any> BatchElems<'any, A, DRSR, P, Self::Params>: Serialize, { async { @@ -107,15 +99,10 @@ pub trait Transport { &mut self, pkg: &mut P, pkgs_aux: &mut PkgsAux, - ) -> impl AsyncBounds + Future> + ) -> impl Future> where A: Api, - DRSR: AsyncBounds, - P: AsyncBounds + Package, - Self: AsyncBounds, - Self::Params: AsyncBounds, - ::ExternalRequestParams: AsyncBounds, - ::ExternalResponseParams: AsyncBounds, + P: Package, { async { let range = self.send_and_retrieve(pkg, pkgs_aux).await?; @@ -136,10 +123,7 @@ pub trait Transport { impl Transport for &mut T where - DRSR: AsyncBounds, - T: AsyncBounds + Transport, - T::Params: AsyncBounds, - Self: AsyncBounds, + T: Transport, { const GROUP: TransportGroup = T::GROUP; type Params = T::Params; @@ -152,7 +136,7 @@ where ) -> Result<(), A::Error> where A: Api, - P: AsyncBounds + Package, + P: Package, { (**self).send(pkg, pkgs_aux).await } @@ -165,7 +149,7 @@ where ) -> Result, A::Error> where A: Api, - P: AsyncBounds + Package, + P: Package, { (**self).send_and_retrieve(pkg, pkgs_aux).await } diff --git a/wtx/src/client_api_framework/network/transport/bi_transport.rs b/wtx/src/client_api_framework/network/transport/bi_transport.rs index 7345b11d..02095fc5 100644 --- a/wtx/src/client_api_framework/network/transport/bi_transport.rs +++ b/wtx/src/client_api_framework/network/transport/bi_transport.rs @@ -1,12 +1,9 @@ -use crate::{ - client_api_framework::{ - dnsn::Deserialize, - misc::log_res, - network::transport::Transport, - pkg::{Package, PkgsAux}, - Api, - }, - misc::AsyncBounds, +use crate::client_api_framework::{ + dnsn::Deserialize, + misc::log_res, + network::transport::Transport, + pkg::{Package, PkgsAux}, + Api, }; use core::{future::Future, ops::Range}; @@ -23,10 +20,9 @@ pub trait BiTransport: Transport { fn retrieve( &mut self, pkgs_aux: &mut PkgsAux, - ) -> impl AsyncBounds + Future>> + ) -> impl Future>> where - A: Api, - A: AsyncBounds; + A: Api; /// Internally calls [Self::retrieve] and then tries to decode the defined response specified /// in [Package::ExternalResponseContent]. @@ -34,13 +30,10 @@ pub trait BiTransport: Transport { fn retrieve_and_decode_contained( &mut self, pkgs_aux: &mut PkgsAux, - ) -> impl AsyncBounds + Future> + ) -> impl Future> where A: Api, - DRSR: AsyncBounds, P: Package, - Self: AsyncBounds, - Self::Params: AsyncBounds, { async { let range = self.retrieve(pkgs_aux).await?; @@ -57,10 +50,7 @@ pub trait BiTransport: Transport { impl BiTransport for &mut T where - DRSR: AsyncBounds, - T: AsyncBounds + BiTransport, - T::Params: AsyncBounds, - Self: AsyncBounds, + T: BiTransport, { #[inline] async fn retrieve( diff --git a/wtx/src/client_api_framework/network/transport/mock.rs b/wtx/src/client_api_framework/network/transport/mock.rs index 2b0de441..b52019ac 100644 --- a/wtx/src/client_api_framework/network/transport/mock.rs +++ b/wtx/src/client_api_framework/network/transport/mock.rs @@ -3,14 +3,11 @@ clippy::indexing_slicing )] -use crate::{ - client_api_framework::{ - misc::{manage_after_sending_related, manage_before_sending_related, FromBytes}, - network::{transport::Transport, TransportGroup}, - pkg::{Package, PkgsAux}, - Api, - }, - misc::AsyncBounds, +use crate::client_api_framework::{ + misc::{manage_after_sending_related, manage_before_sending_related, FromBytes}, + network::{transport::Transport, TransportGroup}, + pkg::{Package, PkgsAux}, + Api, }; use alloc::{ borrow::{Cow, ToOwned}, @@ -91,11 +88,8 @@ where impl Transport for Mock where - DRSR: AsyncBounds, - T: AsyncBounds + AsRef<[u8]> + Debug + PartialEq + ToOwned + 'static + ?Sized, - ::Owned: AsyncBounds + Debug + FromBytes, - for<'owned> &'owned Self: AsyncBounds, - for<'ty> &'ty T: AsyncBounds, + T: AsRef<[u8]> + Debug + PartialEq + ToOwned + 'static + ?Sized, + ::Owned: Debug + FromBytes, { const GROUP: TransportGroup = TransportGroup::Stub; type Params = (); @@ -108,7 +102,7 @@ where ) -> Result<(), A::Error> where A: Api, - P: AsyncBounds + Package, + P: Package, { manage_before_sending_related(pkg, pkgs_aux, &mut *self).await?; self.requests.push(Cow::Owned(FromBytes::from_bytes(&pkgs_aux.byte_buffer)?)); @@ -125,7 +119,7 @@ where ) -> Result, A::Error> where A: Api, - P: AsyncBounds + Package, + P: Package, { >::send(self, pkg, pkgs_aux).await?; let response = self.pop_response()?; diff --git a/wtx/src/client_api_framework/network/transport/reqwest.rs b/wtx/src/client_api_framework/network/transport/reqwest.rs index 8314807b..9bb4b914 100644 --- a/wtx/src/client_api_framework/network/transport/reqwest.rs +++ b/wtx/src/client_api_framework/network/transport/reqwest.rs @@ -8,7 +8,7 @@ use crate::{ pkg::{Package, PkgsAux}, Api, }, - misc::{from_utf8_basic_rslt, AsyncBounds}, + misc::from_utf8_basic_rslt, }; use core::ops::Range; use reqwest::{ @@ -30,10 +30,7 @@ use reqwest::{ /// .await?; /// # Ok(()) } /// ``` -impl Transport for Client -where - DRSR: AsyncBounds, -{ +impl Transport for Client { const GROUP: TransportGroup = TransportGroup::HTTP; type Params = HttpParams; @@ -45,7 +42,7 @@ where ) -> Result<(), A::Error> where A: Api, - P: AsyncBounds + Package, + P: Package, { let _res = response(self, pkg, pkgs_aux).await?; Ok(()) @@ -59,7 +56,7 @@ where ) -> Result, A::Error> where A: Api, - P: AsyncBounds + Package, + P: Package, { let res = response(self, pkg, pkgs_aux).await?; let received_bytes = res.bytes().await.map_err(Into::into)?; @@ -75,7 +72,6 @@ async fn response( ) -> Result where A: Api, - DRSR: AsyncBounds, P: Package, { fn manage_data( diff --git a/wtx/src/client_api_framework/network/transport/std.rs b/wtx/src/client_api_framework/network/transport/std.rs index 4e727540..ad05482c 100644 --- a/wtx/src/client_api_framework/network/transport/std.rs +++ b/wtx/src/client_api_framework/network/transport/std.rs @@ -1,14 +1,11 @@ -use crate::{ - client_api_framework::{ - misc::{manage_after_sending_related, manage_before_sending_related}, - network::{ - transport::{Transport, TransportParams}, - TcpParams, TransportGroup, UdpParams, - }, - pkg::{Package, PkgsAux}, - Api, +use crate::client_api_framework::{ + misc::{manage_after_sending_related, manage_before_sending_related}, + network::{ + transport::{Transport, TransportParams}, + TcpParams, TransportGroup, UdpParams, }, - misc::AsyncBounds, + pkg::{Package, PkgsAux}, + Api, }; use core::ops::Range; use std::{ @@ -16,10 +13,7 @@ use std::{ net::{TcpStream, UdpSocket}, }; -impl Transport for TcpStream -where - DRSR: AsyncBounds, -{ +impl Transport for TcpStream { const GROUP: TransportGroup = TransportGroup::TCP; type Params = TcpParams; @@ -31,7 +25,7 @@ where ) -> Result<(), A::Error> where A: Api, - P: AsyncBounds + Package, + P: Package, { send(pkg, pkgs_aux, self, |bytes, _, trans| Ok(trans.write(bytes)?)).await } @@ -44,16 +38,13 @@ where ) -> Result, A::Error> where A: Api, - P: AsyncBounds + Package, + P: Package, { send_and_retrieve(pkg, pkgs_aux, self, |bytes, _, trans| Ok(trans.read(bytes)?)).await } } -impl Transport for UdpSocket -where - DRSR: AsyncBounds, -{ +impl Transport for UdpSocket { const GROUP: TransportGroup = TransportGroup::UDP; type Params = UdpParams; @@ -65,7 +56,7 @@ where ) -> Result<(), A::Error> where A: Api, - P: AsyncBounds + Package, + P: Package, { send(pkg, pkgs_aux, self, |bytes, ext_req_params, trans| { Ok(trans.send_to(bytes, ext_req_params.url.uri())?) @@ -81,7 +72,7 @@ where ) -> Result, A::Error> where A: Api, - P: AsyncBounds + Package, + P: Package, { send_and_retrieve(pkg, pkgs_aux, self, |bytes, _, trans| Ok(trans.recv(bytes)?)).await } @@ -99,10 +90,8 @@ async fn send( ) -> Result<(), A::Error> where A: Api, - DRSR: AsyncBounds, P: Package, - T: AsyncBounds + Transport, - T::Params: AsyncBounds, + T: Transport, { pkgs_aux.byte_buffer.clear(); manage_before_sending_related(pkg, pkgs_aux, &mut *trans).await?; @@ -138,7 +127,7 @@ async fn send_and_retrieve( ) -> Result, A::Error> where A: Api, - P: AsyncBounds + Package, + P: Package, T: Transport, { trans.send(pkg, pkgs_aux).await?; diff --git a/wtx/src/client_api_framework/network/transport/unit.rs b/wtx/src/client_api_framework/network/transport/unit.rs index 0ff2c47c..eb3ab756 100644 --- a/wtx/src/client_api_framework/network/transport/unit.rs +++ b/wtx/src/client_api_framework/network/transport/unit.rs @@ -1,11 +1,8 @@ -use crate::{ - client_api_framework::{ - misc::{manage_after_sending_related, manage_before_sending_related}, - network::{transport::Transport, TransportGroup}, - pkg::{Package, PkgsAux}, - Api, - }, - misc::AsyncBounds, +use crate::client_api_framework::{ + misc::{manage_after_sending_related, manage_before_sending_related}, + network::{transport::Transport, TransportGroup}, + pkg::{Package, PkgsAux}, + Api, }; use core::ops::Range; @@ -18,10 +15,7 @@ use core::ops::Range; /// ().send_retrieve_and_decode_contained(&mut (), &mut PkgsAux::from_minimum((), (), ())).await?; /// # Ok(()) } /// ``` -impl Transport for () -where - DRSR: AsyncBounds, -{ +impl Transport for () { const GROUP: TransportGroup = TransportGroup::Stub; type Params = (); @@ -33,7 +27,7 @@ where ) -> Result<(), A::Error> where A: Api, - P: AsyncBounds + Package, + P: Package, { manage_before_sending_related(pkg, pkgs_aux, self).await?; manage_after_sending_related(pkg, pkgs_aux).await?; @@ -48,7 +42,7 @@ where ) -> Result, A::Error> where A: Api, - P: AsyncBounds + Package, + P: Package, { self.send(pkg, pkgs_aux).await?; Ok(0..0) diff --git a/wtx/src/client_api_framework/network/transport/wtx.rs b/wtx/src/client_api_framework/network/transport/wtx.rs index d2178fdf..bb7978ec 100644 --- a/wtx/src/client_api_framework/network/transport/wtx.rs +++ b/wtx/src/client_api_framework/network/transport/wtx.rs @@ -8,7 +8,7 @@ use crate::{ pkg::{Package, PkgsAux}, Api, }, - misc::{AsyncBounds, Stream}, + misc::Stream, rng::Rng, web_socket::{ compression::NegotiatedCompression, FrameBufferVec, FrameBufferVecMut, FrameMutVec, OpCode, @@ -19,16 +19,10 @@ use core::{borrow::BorrowMut, ops::Range}; impl Transport for (FrameBufferVec, WebSocketClient) where - DRSR: AsyncBounds, - NC: AsyncBounds + NegotiatedCompression, - RNG: AsyncBounds + Rng, - S: AsyncBounds + Stream, - WSB: AsyncBounds + BorrowMut, - for<'ty> &'ty DRSR: AsyncBounds, - for<'ty> &'ty NC: AsyncBounds, - for<'ty> &'ty RNG: AsyncBounds, - for<'ty> &'ty S: AsyncBounds, - for<'ty> &'ty WSB: AsyncBounds, + NC: NegotiatedCompression, + RNG: Rng, + S: Stream, + WSB: BorrowMut, { const GROUP: TransportGroup = TransportGroup::WebSocket; type Params = WsParams; @@ -41,7 +35,7 @@ where ) -> Result<(), A::Error> where A: Api, - P: AsyncBounds + Package, + P: Package, { send(&mut self.0, pkg, pkgs_aux, &mut self.1).await } @@ -54,7 +48,7 @@ where ) -> Result, A::Error> where A: Api, - P: AsyncBounds + Package, + P: Package, { send_and_retrieve(&mut self.0, pkg, pkgs_aux, &mut self.1).await } @@ -62,16 +56,10 @@ where impl BiTransport for (FrameBufferVec, WebSocketClient) where - DRSR: AsyncBounds, - NC: AsyncBounds + NegotiatedCompression, - RNG: AsyncBounds + Rng, - S: AsyncBounds + Stream, - WSB: AsyncBounds + BorrowMut, - for<'ty> &'ty DRSR: AsyncBounds, - for<'ty> &'ty NC: AsyncBounds, - for<'ty> &'ty RNG: AsyncBounds, - for<'ty> &'ty S: AsyncBounds, - for<'ty> &'ty WSB: AsyncBounds, + NC: NegotiatedCompression, + RNG: Rng, + S: Stream, + WSB: BorrowMut, { #[inline] async fn retrieve( @@ -88,16 +76,10 @@ where impl Transport for (&mut FrameBufferVec, &mut WebSocketClient) where - DRSR: AsyncBounds, - NC: AsyncBounds + NegotiatedCompression, - RNG: AsyncBounds + Rng, - S: AsyncBounds + Stream, - WSB: AsyncBounds + BorrowMut, - for<'ty> &'ty DRSR: AsyncBounds, - for<'ty> &'ty NC: AsyncBounds, - for<'ty> &'ty RNG: AsyncBounds, - for<'ty> &'ty S: AsyncBounds, - for<'ty> &'ty WSB: AsyncBounds, + NC: NegotiatedCompression, + RNG: Rng, + S: Stream, + WSB: BorrowMut, { const GROUP: TransportGroup = TransportGroup::WebSocket; type Params = WsParams; @@ -110,7 +92,7 @@ where ) -> Result<(), A::Error> where A: Api, - P: AsyncBounds + Package, + P: Package, { send(self.0, pkg, pkgs_aux, self.1).await } @@ -123,7 +105,7 @@ where ) -> Result, A::Error> where A: Api, - P: AsyncBounds + Package, + P: Package, { send_and_retrieve(self.0, pkg, pkgs_aux, self.1).await } @@ -132,16 +114,10 @@ where impl BiTransport for (&mut FrameBufferVec, &mut WebSocketClient) where - DRSR: AsyncBounds, - NC: AsyncBounds + NegotiatedCompression, - RNG: AsyncBounds + Rng, - S: AsyncBounds + Stream, - WSB: AsyncBounds + BorrowMut, - for<'ty> &'ty DRSR: AsyncBounds, - for<'ty> &'ty NC: AsyncBounds, - for<'ty> &'ty RNG: AsyncBounds, - for<'ty> &'ty S: AsyncBounds, - for<'ty> &'ty WSB: AsyncBounds, + NC: NegotiatedCompression, + RNG: Rng, + S: Stream, + WSB: BorrowMut, { #[inline] async fn retrieve( @@ -160,16 +136,10 @@ async fn retrieve( ws: &mut WebSocketClient, ) -> crate::Result> where - DRSR: AsyncBounds, - NC: AsyncBounds + NegotiatedCompression, - RNG: AsyncBounds + Rng, - S: AsyncBounds + Stream, - WSB: AsyncBounds + BorrowMut, - for<'ty> &'ty DRSR: AsyncBounds, - for<'ty> &'ty NC: AsyncBounds, - for<'ty> &'ty RNG: AsyncBounds, - for<'ty> &'ty S: AsyncBounds, - for<'ty> &'ty WSB: AsyncBounds, + NC: NegotiatedCompression, + RNG: Rng, + S: Stream, + WSB: BorrowMut, { pkgs_aux.byte_buffer.clear(); let fb = &mut FrameBufferVecMut::from(&mut pkgs_aux.byte_buffer); @@ -189,17 +159,11 @@ async fn send( ) -> Result<(), A::Error> where A: Api, - DRSR: AsyncBounds, - NC: AsyncBounds + NegotiatedCompression, - P: AsyncBounds + Package, - RNG: AsyncBounds + Rng, - S: AsyncBounds + Stream, - WSB: AsyncBounds + BorrowMut, - for<'ty> &'ty DRSR: AsyncBounds, - for<'ty> &'ty NC: AsyncBounds, - for<'ty> &'ty RNG: AsyncBounds, - for<'ty> &'ty S: AsyncBounds, - for<'ty> &'ty WSB: AsyncBounds, + NC: NegotiatedCompression, + P: Package, + RNG: Rng, + S: Stream, + WSB: BorrowMut, { let mut trans = (fb, ws); pkgs_aux.byte_buffer.clear(); @@ -224,17 +188,11 @@ async fn send_and_retrieve( ) -> Result, A::Error> where A: Api, - DRSR: AsyncBounds, - NC: AsyncBounds + NegotiatedCompression, - P: AsyncBounds + Package, - RNG: AsyncBounds + Rng, - S: AsyncBounds + Stream, - WSB: AsyncBounds + BorrowMut, - for<'ty> &'ty DRSR: AsyncBounds, - for<'ty> &'ty NC: AsyncBounds, - for<'ty> &'ty RNG: AsyncBounds, - for<'ty> &'ty S: AsyncBounds, - for<'ty> &'ty WSB: AsyncBounds, + NC: NegotiatedCompression, + P: Package, + RNG: Rng, + S: Stream, + WSB: BorrowMut, { send(fb, pkg, pkgs_aux, ws).await?; let fb = &mut FrameBufferVecMut::from(&mut pkgs_aux.byte_buffer); diff --git a/wtx/src/client_api_framework/pkg.rs b/wtx/src/client_api_framework/pkg.rs index ff2b2b24..04457115 100644 --- a/wtx/src/client_api_framework/pkg.rs +++ b/wtx/src/client_api_framework/pkg.rs @@ -6,13 +6,10 @@ mod batch_pkg; mod pkg_with_helper; mod pkgs_aux; -use crate::{ - client_api_framework::{ - dnsn::{Deserialize, Serialize}, - network::transport::TransportParams, - Api, - }, - misc::AsyncBounds, +use crate::client_api_framework::{ + dnsn::{Deserialize, Serialize}, + network::transport::TransportParams, + Api, }; pub use batch_pkg::{BatchElems, BatchPkg}; use core::future::Future; @@ -46,7 +43,7 @@ where &mut self, _: &mut A, _: &mut TP::ExternalResponseParams, - ) -> impl AsyncBounds + Future> { + ) -> impl Future> { async { Ok(()) } } @@ -58,7 +55,7 @@ where _: &mut A, _: &mut TP::ExternalRequestParams, _: &[u8], - ) -> impl AsyncBounds + Future> { + ) -> impl Future> { async { Ok(()) } } @@ -112,10 +109,7 @@ impl Package for &mut P where A: Api, P: Package, - TP: AsyncBounds + TransportParams, - TP::ExternalRequestParams: AsyncBounds, - TP::ExternalResponseParams: AsyncBounds, - Self: AsyncBounds, + TP: TransportParams, { type ExternalRequestContent = P::ExternalRequestContent; type ExternalResponseContent = P::ExternalResponseContent; diff --git a/wtx/src/client_api_framework/pkg/batch_pkg.rs b/wtx/src/client_api_framework/pkg/batch_pkg.rs index e96277c2..6b4b8afe 100644 --- a/wtx/src/client_api_framework/pkg/batch_pkg.rs +++ b/wtx/src/client_api_framework/pkg/batch_pkg.rs @@ -1,11 +1,8 @@ -use crate::{ - client_api_framework::{ - dnsn::{Deserialize, Serialize}, - network::transport::TransportParams, - pkg::Package, - Api, Id, - }, - misc::AsyncBounds, +use crate::client_api_framework::{ + dnsn::{Deserialize, Serialize}, + network::transport::TransportParams, + pkg::Package, + Api, Id, }; use cl_aux::DynContigColl; use core::{borrow::Borrow, marker::PhantomData}; @@ -105,11 +102,8 @@ impl<'slice, A, DRSR, P, TP> Package for BatchPkg<'slice, A, DRSR, where A: Api, BatchElems<'slice, A, DRSR, P, TP>: Serialize, - DRSR: AsyncBounds, - P: AsyncBounds + Package, - TP: AsyncBounds + TransportParams, - TP::ExternalRequestParams: AsyncBounds, - TP::ExternalResponseParams: AsyncBounds, + P: Package, + TP: TransportParams, { type ExternalRequestContent = BatchElems<'slice, A, DRSR, P, TP>; type ExternalResponseContent = (); diff --git a/wtx/src/client_api_framework/pkg/pkg_with_helper.rs b/wtx/src/client_api_framework/pkg/pkg_with_helper.rs index 9b6769de..3ce4afd9 100644 --- a/wtx/src/client_api_framework/pkg/pkg_with_helper.rs +++ b/wtx/src/client_api_framework/pkg/pkg_with_helper.rs @@ -1,8 +1,5 @@ -use crate::{ - client_api_framework::{ - data_format::JsonRpcRequest, network::transport::TransportParams, pkg::Package, Api, Id, - }, - misc::AsyncBounds, +use crate::client_api_framework::{ + data_format::JsonRpcRequest, network::transport::TransportParams, pkg::Package, Api, Id, }; use core::{ borrow::Borrow, @@ -35,11 +32,8 @@ impl PkgWithHelper { impl Package for PkgWithHelper where A: Api, - H: AsyncBounds, - P: AsyncBounds + Package, - TP: AsyncBounds + TransportParams, - TP::ExternalRequestParams: AsyncBounds, - TP::ExternalResponseParams: AsyncBounds, + P: Package, + TP: TransportParams, { type ExternalRequestContent = P::ExternalRequestContent; type ExternalResponseContent = P::ExternalResponseContent; diff --git a/wtx/src/database/client/postgres/executor.rs b/wtx/src/database/client/postgres/executor.rs index 4c54fcc9..5eb7a0bb 100644 --- a/wtx/src/database/client/postgres/executor.rs +++ b/wtx/src/database/client/postgres/executor.rs @@ -14,7 +14,7 @@ use crate::{ }, Database, RecordValues, StmtCmd, TransactionManager as _, }, - misc::{FilledBufferWriter, Stream, TlsStream}, + misc::{AsyncBounds, FilledBufferWriter, Stream, TlsStream}, rng::Rng, }; use core::{borrow::BorrowMut, future::Future, marker::PhantomData}; @@ -113,9 +113,9 @@ where impl crate::database::Executor for Executor where - E: From, - EB: BorrowMut, - S: Stream, + E: AsyncBounds + From, + EB: AsyncBounds + BorrowMut, + S: AsyncBounds + Stream, { type Database = Postgres; type TransactionManager<'tm> = TransactionManager<'tm, E, EB, S> @@ -191,15 +191,15 @@ where } #[inline] - async fn fetch_many_with_stmt<'this, SC, RV>( - &'this mut self, + async fn fetch_many_with_stmt( + &mut self, sc: SC, rv: RV, - mut cb: impl FnMut(&::Record<'_>) -> Result<(), E> + 'this, + mut cb: impl AsyncBounds + FnMut(&::Record<'_>) -> Result<(), E>, ) -> Result<::Records<'_>, E> where - RV: RecordValues, - SC: StmtCmd, + RV: AsyncBounds + RecordValues, + SC: AsyncBounds + StmtCmd, { let ExecutorBufferPartsMut { nb, rb, stmts, vb, .. } = self.eb.borrow_mut().parts_mut(); ExecutorBuffer::clear_cmd_buffers(nb, rb, vb); diff --git a/wtx/src/database/executor.rs b/wtx/src/database/executor.rs index f3a3fb18..72e7e1a0 100644 --- a/wtx/src/database/executor.rs +++ b/wtx/src/database/executor.rs @@ -1,6 +1,9 @@ //! Database -use crate::database::{Database, FromRecord, RecordValues, StmtCmd, TransactionManager}; +use crate::{ + database::{Database, FromRecord, RecordValues, StmtCmd, TransactionManager}, + misc::AsyncBounds, +}; use alloc::vec::Vec; use core::future::Future; @@ -16,7 +19,11 @@ pub trait Executor { /// Allows the evaluation of severals commands returning the number of affected records on each `cb` call. /// /// Commands are not cached or inspected for potential vulnerabilities. - fn execute(&mut self, cmd: &str, cb: impl FnMut(u64)) -> impl Future>; + fn execute( + &mut self, + cmd: &str, + cb: impl AsyncBounds + FnMut(u64), + ) -> impl AsyncBounds + Future>; /// Executes a **single** statement automatically binding the values of `rv` to the referenced /// `stmt` and then returns the number of affected records. @@ -24,10 +31,10 @@ pub trait Executor { &mut self, sc: SC, rv: RV, - ) -> impl Future::Error>> + ) -> impl AsyncBounds + Future::Error>> where - RV: RecordValues, - SC: StmtCmd; + RV: AsyncBounds + RecordValues, + SC: AsyncBounds + StmtCmd; /// Executes a **single** statement automatically binding the values of `rv` to the referenced /// `stmt` and then returns a **single** record. @@ -35,29 +42,31 @@ pub trait Executor { &mut self, sc: SC, sv: RV, - ) -> impl Future< + ) -> impl AsyncBounds + + Future< Output = Result<::Record<'_>, ::Error>, > where - RV: RecordValues, - SC: StmtCmd; + RV: AsyncBounds + RecordValues, + SC: AsyncBounds + StmtCmd; /// Executes a **single** statement automatically binding the values of `rv` to the referenced /// `stmt` and then returns a **set** of records. - fn fetch_many_with_stmt<'this, SC, RV>( - &'this mut self, + fn fetch_many_with_stmt( + &mut self, sc: SC, sv: RV, - cb: impl FnMut( + cb: impl AsyncBounds + + FnMut( &::Record<'_>, - ) -> Result<(), ::Error> - + 'this, - ) -> impl Future< + ) -> Result<(), ::Error>, + ) -> impl AsyncBounds + + Future< Output = Result<::Records<'_>, ::Error>, > where - RV: RecordValues, - SC: StmtCmd; + RV: AsyncBounds + RecordValues, + SC: AsyncBounds + StmtCmd; /// Sometimes the backend can discontinue the connection. fn is_closed(&self) -> bool; @@ -69,7 +78,7 @@ pub trait Executor { fn prepare( &mut self, cmd: &str, - ) -> impl Future::Error>>; + ) -> impl AsyncBounds + Future::Error>>; /// Retrieves a record and maps it to `T`. See [FromRecord]. #[inline] @@ -77,10 +86,11 @@ pub trait Executor { &mut self, cmd: &str, sv: SV, - ) -> impl Future::Error>> + ) -> impl AsyncBounds + Future::Error>> where - T: for<'rec> FromRecord, - SV: RecordValues, + T: AsyncBounds + FromRecord, + SV: AsyncBounds + RecordValues, + for<'any> &'any mut Self: AsyncBounds, { async move { T::from_record(&self.fetch_with_stmt(cmd, sv).await?) } } @@ -92,10 +102,11 @@ pub trait Executor { cmd: &str, results: &mut Vec, sv: SV, - ) -> impl Future::Error>> + ) -> impl AsyncBounds + Future::Error>> where - SV: RecordValues, - T: for<'rec> FromRecord, + SV: AsyncBounds + RecordValues, + T: AsyncBounds + FromRecord, + for<'any> &'any mut Self: AsyncBounds, { async move { let _records = self @@ -110,7 +121,9 @@ pub trait Executor { /// Initially calls `begin` and the returns [Self::TransactionManager], which implies in an /// following mandatory `commit` call by the caller. - fn transaction(&mut self) -> impl Future>>; + fn transaction( + &mut self, + ) -> impl AsyncBounds + Future>>; } impl Executor for () { @@ -149,18 +162,18 @@ impl Executor for () { } #[inline] - async fn fetch_many_with_stmt<'this, SC, RV>( - &'this mut self, + async fn fetch_many_with_stmt( + &mut self, _: SC, _: RV, - _: impl FnMut( + _: impl AsyncBounds + + FnMut( &::Record<'_>, - ) -> Result<(), ::Error> - + 'this, + ) -> Result<(), ::Error>, ) -> Result<(), ::Error> where - RV: RecordValues, - SC: StmtCmd, + RV: AsyncBounds + RecordValues, + SC: AsyncBounds + StmtCmd, { Ok(()) } diff --git a/wtx/src/database/from_record.rs b/wtx/src/database/from_record.rs index 07b8b27b..58afd3f8 100644 --- a/wtx/src/database/from_record.rs +++ b/wtx/src/database/from_record.rs @@ -9,3 +9,13 @@ where /// Fallible entry-point that maps the element. fn from_record(record: &D::Record<'_>) -> Result; } + +impl FromRecord for () +where + D: Database, +{ + #[inline] + fn from_record(_: &D::Record<'_>) -> Result { + Ok(()) + } +} diff --git a/wtx/src/database/from_records.rs b/wtx/src/database/from_records.rs index f5debeab..6076893a 100644 --- a/wtx/src/database/from_records.rs +++ b/wtx/src/database/from_records.rs @@ -15,3 +15,18 @@ where table_suffix: TableSuffix, ) -> Result<(usize, Self), D::Error>; } + +impl FromRecords for () +where + D: Database, +{ + #[inline] + fn from_records( + _: &mut String, + _: &D::Record<'_>, + _: &D::Records<'_>, + _: TableSuffix, + ) -> Result<(usize, Self), D::Error> { + Ok((0, ())) + } +} diff --git a/wtx/src/database/orm/crud.rs b/wtx/src/database/orm/crud.rs index 8e77a02e..8c227010 100644 --- a/wtx/src/database/orm/crud.rs +++ b/wtx/src/database/orm/crud.rs @@ -1,10 +1,13 @@ -use crate::database::{ - executor::Executor, - orm::{ - seek_related_entities, write_select_field, InitialInsertValue, SelectLimit, SelectOrderBy, - SqlWriter, Table, TableParams, +use crate::{ + database::{ + executor::Executor, + orm::{ + seek_related_entities, write_select_field, InitialInsertValue, SelectLimit, SelectOrderBy, + SqlWriter, Table, TableParams, + }, + Database, Decode, FromRecords, Records, ValueIdent, }, - Database, Decode, FromRecords, Records, ValueIdent, + misc::AsyncBounds, }; use alloc::{string::String, vec::Vec}; use core::{fmt::Write, future::Future}; @@ -17,10 +20,13 @@ pub trait Crud: Executor { buffer_cmd: &mut String, table: &'entity T, table_params: &mut TableParams<'entity, T>, - ) -> impl Future> + ) -> impl AsyncBounds + Future> where T: Table<'entity, Error = ::Error>, T::Associations: SqlWriter, + for<'any> &'any mut Self: AsyncBounds, + for<'any> &'any mut TableParams<'entity, T>: AsyncBounds, + for<'any> &'any T: AsyncBounds, { async move { table_params.update_all_table_fields(table); @@ -40,10 +46,13 @@ pub trait Crud: Executor { buffer_cmd: &mut String, table: &'entity T, table_params: &mut TableParams<'entity, T>, - ) -> impl Future> + ) -> impl AsyncBounds + Future> where T: Table<'entity, Error = ::Error>, T::Associations: SqlWriter, + for<'any> &'any mut Self: AsyncBounds, + for<'any> &'any mut TableParams<'entity, T>: AsyncBounds, + for<'any> &'any T: AsyncBounds, { async move { table_params.update_all_table_fields(table); @@ -59,12 +68,15 @@ pub trait Crud: Executor { buffer_cmd: &mut String, results: &mut Vec, tp: &TableParams<'entity, T>, - ) -> impl Future>::Error>> + ) -> impl AsyncBounds + Future::Error>> where T: FromRecords + Table<'entity, Error = ::Error>, - T::Associations: SqlWriter>::Error>, + T::Associations: SqlWriter::Error>, str: for<'rec> ValueIdent<::Record<'rec>>, u64: for<'value> Decode<'value, Self::Database>, + for<'any> &'any mut Self: AsyncBounds, + for<'any> &'any mut Vec: AsyncBounds, + for<'any> &'any TableParams<'entity, T>: AsyncBounds, { async move { tp.write_select(buffer_cmd, SelectOrderBy::Ascending, SelectLimit::All, &mut |_| Ok(()))?; @@ -84,12 +96,15 @@ pub trait Crud: Executor { select_limit: SelectLimit, tp: &TableParams<'entity, T>, where_str: &str, - ) -> impl Future>::Error>> + ) -> impl AsyncBounds + Future::Error>> where T: FromRecords + Table<'entity, Error = ::Error>, - T::Associations: SqlWriter>::Error>, + T::Associations: SqlWriter::Error>, str: for<'rec> ValueIdent<::Record<'rec>>, u64: for<'value> Decode<'value, Self::Database>, + for<'any> &'any mut Self: AsyncBounds, + for<'any> &'any mut Vec: AsyncBounds, + for<'any> &'any TableParams<'entity, T>: AsyncBounds, { async move { tp.write_select(buffer_cmd, order_by, select_limit, &mut |b| { @@ -109,10 +124,13 @@ pub trait Crud: Executor { buffer_cmd: &mut String, id: T::PrimaryKeyValue, tp: &TableParams<'entity, T>, - ) -> impl Future>::Error>> + ) -> impl AsyncBounds + Future::Error>> where T: FromRecords + Table<'entity, Error = ::Error>, - T::Associations: SqlWriter>::Error>, + T::Associations: SqlWriter::Error>, + T::PrimaryKeyValue: AsyncBounds, + for<'any> &'any mut Self: AsyncBounds, + for<'any> &'any TableParams<'entity, T>: AsyncBounds, { async move { tp.write_select(buffer_cmd, SelectOrderBy::Ascending, SelectLimit::All, &mut |b| { @@ -138,10 +156,13 @@ pub trait Crud: Executor { buffer_cmd: &mut String, table: &'entity T, table_params: &mut TableParams<'entity, T>, - ) -> impl Future> + ) -> impl AsyncBounds + Future> where T: Table<'entity, Error = ::Error>, T::Associations: SqlWriter, + for<'any> &'any mut Self: AsyncBounds, + for<'any> &'any mut TableParams<'entity, T>: AsyncBounds, + for<'any> &'any T: AsyncBounds, { async move { table_params.update_all_table_fields(table); diff --git a/wtx/src/database/orm/sql_value.rs b/wtx/src/database/orm/sql_value.rs index 49f986e6..bc4f8a95 100644 --- a/wtx/src/database/orm/sql_value.rs +++ b/wtx/src/database/orm/sql_value.rs @@ -7,6 +7,13 @@ pub trait SqlValue { fn write(&self, buffer_cmd: &mut String) -> Result<(), E>; } +impl SqlValue for () { + #[inline] + fn write(&self, _: &mut String) -> Result<(), E> { + Ok(()) + } +} + impl SqlValue for &'_ T where T: SqlValue, diff --git a/wtx/src/database/orm/sql_writer.rs b/wtx/src/database/orm/sql_writer.rs index a0658eca..50a78cb4 100644 --- a/wtx/src/database/orm/sql_writer.rs +++ b/wtx/src/database/orm/sql_writer.rs @@ -50,6 +50,59 @@ pub trait SqlWriter { fn write_update(&self, aux: &mut AuxNodes, buffer_cmd: &mut String) -> Result<(), Self::Error>; } +impl SqlWriter for () { + type Error = crate::Error; + + #[inline] + fn write_delete(&self, _: &mut AuxNodes, _: &mut String) -> Result<(), Self::Error> { + Ok(()) + } + + #[inline] + fn write_insert( + &self, + _: &mut AuxNodes, + _: &mut String, + _: &mut Option>, + ) -> Result<(), Self::Error> + where + V: Display, + { + Ok(()) + } + + #[inline] + fn write_select( + &self, + _: &mut String, + _: SelectOrderBy, + _: SelectLimit, + _: &mut impl FnMut(&mut String) -> Result<(), Self::Error>, + ) -> Result<(), Self::Error> { + Ok(()) + } + + #[inline] + fn write_select_associations(&self, _: &mut String) -> Result<(), Self::Error> { + Ok(()) + } + + #[inline] + fn write_select_fields(&self, _: &mut String) -> Result<(), Self::Error> { + Ok(()) + } + + #[inline] + fn write_select_orders_by(&self, _: &mut String) -> Result<(), Self::Error> { + Ok(()) + } + + #[inline] + fn write_update(&self, _: &mut AuxNodes, _: &mut String) -> Result<(), Self::Error> { + Ok(()) + } +} + impl<'entity, T> SqlWriter for TableParams<'entity, T> where T: Table<'entity>, diff --git a/wtx/src/database/orm/table.rs b/wtx/src/database/orm/table.rs index f301ed7b..39d59b07 100644 --- a/wtx/src/database/orm/table.rs +++ b/wtx/src/database/orm/table.rs @@ -28,3 +28,23 @@ pub trait Table<'entity>: Sized { /// Updates the inner instance values that are used by some CRUD operations fn update_all_table_fields(entity: &'entity Self, table: &mut TableParams<'entity, Self>); } + +impl<'entity> Table<'entity> for () { + const PRIMARY_KEY_NAME: &'static str = ""; + const TABLE_NAME: &'static str = ""; + + type Associations = (); + type Error = crate::Error; + type Fields = (); + type PrimaryKeyValue = &'static str; + + #[inline] + fn type_instances(_: TableSuffix) -> FromSuffixRslt<'entity, Self> { + todo!() + } + + #[inline] + fn update_all_table_fields(_: &'entity Self, _: &mut TableParams<'entity, Self>) { + todo!() + } +} diff --git a/wtx/src/database/orm/table_associations.rs b/wtx/src/database/orm/table_associations.rs index 9fcd6c40..20126def 100644 --- a/wtx/src/database/orm/table_associations.rs +++ b/wtx/src/database/orm/table_associations.rs @@ -8,3 +8,12 @@ pub trait TableAssociations { /// Yields all table associations fn full_associations(&self) -> Self::FullTableAssociations; } + +impl TableAssociations for () { + type FullTableAssociations = core::array::IntoIter; + + #[inline] + fn full_associations(&self) -> Self::FullTableAssociations { + [].into_iter() + } +} diff --git a/wtx/src/database/schema_manager.rs b/wtx/src/database/schema_manager.rs index f77e447a..c763bc1f 100644 --- a/wtx/src/database/schema_manager.rs +++ b/wtx/src/database/schema_manager.rs @@ -170,14 +170,14 @@ mod postgres { }, DatabaseTy, Executor as _, Identifier, }, - misc::Stream, + misc::{AsyncBounds, Stream}, }; use core::borrow::BorrowMut; impl SchemaManagement for Executor where - EB: BorrowMut, - STREAM: Stream, + EB: AsyncBounds + BorrowMut, + STREAM: AsyncBounds + Stream, { #[inline] async fn clear(&mut self, buffer: (&mut String, &mut Vec)) -> crate::Result<()> { diff --git a/wtx/src/database/schema_manager/fixed_sql_commands.rs b/wtx/src/database/schema_manager/fixed_sql_commands.rs index 45bb66f9..73d46189 100644 --- a/wtx/src/database/schema_manager/fixed_sql_commands.rs +++ b/wtx/src/database/schema_manager/fixed_sql_commands.rs @@ -28,10 +28,13 @@ macro_rules! _serial_id { #[cfg(feature = "postgres")] pub(crate) mod postgres; -use crate::database::{ - executor::Executor, - schema_manager::{DbMigration, MigrationGroup, UserMigration}, - Database, DatabaseTy, FromRecord, TransactionManager, +use crate::{ + database::{ + executor::Executor, + schema_manager::{DbMigration, MigrationGroup, UserMigration}, + Database, DatabaseTy, FromRecord, TransactionManager, + }, + misc::AsyncBounds, }; use alloc::{string::String, vec::Vec}; use core::fmt::Write; @@ -45,7 +48,7 @@ pub(crate) async fn _delete_migrations( version: i32, ) -> crate::Result<()> where - E: Executor, + E: AsyncBounds + Executor, S: AsRef, { buffer_cmd.write_fmt(format_args!( @@ -67,7 +70,7 @@ pub(crate) async fn _insert_migrations<'migration, DBS, E, I, S>( ) -> crate::Result<()> where DBS: AsRef<[DatabaseTy]> + 'migration, - E: Executor, + E: AsyncBounds + Executor, I: Clone + Iterator>, S: AsRef + 'migration, { @@ -123,7 +126,7 @@ pub(crate) async fn _migrations_by_mg_version_query( ) -> crate::Result<()> where D: Database, - E: Executor, + E: AsyncBounds + Executor, DbMigration: for<'rec> FromRecord, { buffer_cmd.write_fmt(format_args!( diff --git a/wtx/src/database/schema_manager/fixed_sql_commands/postgres.rs b/wtx/src/database/schema_manager/fixed_sql_commands/postgres.rs index c9af8bb1..11803c44 100644 --- a/wtx/src/database/schema_manager/fixed_sql_commands/postgres.rs +++ b/wtx/src/database/schema_manager/fixed_sql_commands/postgres.rs @@ -1,5 +1,6 @@ -use crate::database::{ - client::postgres::Postgres, executor::Executor, Identifier, TransactionManager, +use crate::{ + database::{client::postgres::Postgres, executor::Executor, Identifier, TransactionManager}, + misc::AsyncBounds, }; use alloc::{string::String, vec::Vec}; use core::fmt::Write; @@ -22,7 +23,7 @@ pub(crate) async fn _clear( executor: &mut E, ) -> crate::Result<()> where - E: Executor>, + E: AsyncBounds + Executor>, { _schemas(executor, buffer_idents).await?; _push_drop((buffer_cmd, buffer_idents), "SCHEMA")?; @@ -62,7 +63,7 @@ pub(crate) async fn _domains( results: &mut Vec, ) -> crate::Result<()> where - E: Executor>, + E: AsyncBounds + Executor>, { executor .simple_entities( @@ -86,7 +87,7 @@ where #[inline] pub(crate) async fn _enums(executor: &mut E, results: &mut Vec) -> crate::Result<()> where - E: Executor>, + E: AsyncBounds + Executor>, { executor .simple_entities( @@ -111,7 +112,7 @@ pub(crate) async fn _pg_proc( prokind: char, ) -> crate::Result<()> where - E: Executor>, + E: AsyncBounds + Executor>, { let before = buffer_cmd.len(); buffer_cmd.write_fmt(format_args!( @@ -140,7 +141,7 @@ pub(crate) async fn _sequences( results: &mut Vec, ) -> crate::Result<()> where - E: Executor>, + E: AsyncBounds + Executor>, { executor .simple_entities( @@ -163,7 +164,7 @@ pub(crate) async fn _schemas( identifiers: &mut Vec, ) -> crate::Result<()> where - E: Executor>, + E: AsyncBounds + Executor>, { executor .simple_entities( @@ -189,7 +190,7 @@ pub(crate) async fn _table_names( schema: &str, ) -> crate::Result<()> where - E: Executor>, + E: AsyncBounds + Executor>, { let before = buffer_cmd.len(); buffer_cmd.write_fmt(format_args!( @@ -220,7 +221,7 @@ where #[inline] pub(crate) async fn _types(executor: &mut E, results: &mut Vec) -> crate::Result<()> where - E: Executor>, + E: AsyncBounds + Executor>, { executor .simple_entities( @@ -250,7 +251,7 @@ where #[inline] pub(crate) async fn _views(executor: &mut E, results: &mut Vec) -> crate::Result<()> where - E: Executor>, + E: AsyncBounds + Executor>, { executor .simple_entities( diff --git a/wtx/src/database/schema_manager/integration_tests/db/postgres.rs b/wtx/src/database/schema_manager/integration_tests/db/postgres.rs index 800eae3c..184c49d1 100644 --- a/wtx/src/database/schema_manager/integration_tests/db/postgres.rs +++ b/wtx/src/database/schema_manager/integration_tests/db/postgres.rs @@ -1,8 +1,11 @@ #[cfg(feature = "schema-manager-dev")] -use crate::database::{ - client::postgres::Postgres, schema_manager::fixed_sql_commands::postgres, - schema_manager::integration_tests, schema_manager::Commands, schema_manager::DbMigration, - schema_manager::SchemaManagement, FromRecord, Identifier, +use crate::{ + database::{ + client::postgres::Postgres, schema_manager::fixed_sql_commands::postgres, + schema_manager::integration_tests, schema_manager::Commands, schema_manager::DbMigration, + schema_manager::SchemaManagement, FromRecord, Identifier, + }, + misc::AsyncBounds, }; #[cfg(feature = "schema-manager-dev")] @@ -11,7 +14,7 @@ pub(crate) async fn _clean_drops_all_objs( c: &mut Commands, _: integration_tests::AuxTestParams, ) where - E: SchemaManagement>, + E: AsyncBounds + SchemaManagement>, Identifier: FromRecord>, { integration_tests::create_foo_table(buffer_cmd, c, "public.").await; diff --git a/wtx/src/misc/stream.rs b/wtx/src/misc/stream.rs index b7ca4fa4..5a0c65f3 100644 --- a/wtx/src/misc/stream.rs +++ b/wtx/src/misc/stream.rs @@ -3,7 +3,7 @@ use alloc::vec::Vec; use core::{cmp::Ordering, future::Future}; /// A stream of values produced asynchronously. -pub trait Stream: AsyncBounds { +pub trait Stream { /// Pulls some bytes from this source into the specified buffer, returning how many bytes /// were read. fn read(&mut self, bytes: &mut [u8]) -> impl AsyncBounds + Future>; diff --git a/wtx/src/pool_manager/resource_manager.rs b/wtx/src/pool_manager/resource_manager.rs index 9c78411a..ede30988 100644 --- a/wtx/src/pool_manager/resource_manager.rs +++ b/wtx/src/pool_manager/resource_manager.rs @@ -18,6 +18,23 @@ pub trait ResourceManager { -> impl Future>; } +impl ResourceManager for () { + type Error = crate::Error; + type Resource = (); + + async fn create(&self) -> Result { + Ok(()) + } + + fn is_invalid(&self, _: &Self::Resource) -> bool { + false + } + + async fn recycle(&self, _: &mut Self::Resource) -> Result<(), Self::Error> { + Ok(()) + } +} + /// Manages generic resources that are always valid and don't require logic for recycling. #[derive(Debug)] pub struct SimpleRM { diff --git a/wtx/src/web_socket/handshake.rs b/wtx/src/web_socket/handshake.rs index 8c14611d..7aaac063 100644 --- a/wtx/src/web_socket/handshake.rs +++ b/wtx/src/web_socket/handshake.rs @@ -8,7 +8,6 @@ mod tests; use crate::{ http::Request, - misc::AsyncBounds, web_socket::{WebSocketClient, WebSocketServer}, }; use core::future::Future; @@ -19,8 +18,8 @@ pub trait WebSocketAccept { /// Reads external data to figure out if incoming requests can be accepted as WebSocket connections. fn accept( self, - cb: impl AsyncBounds + FnOnce(&dyn Request) -> bool, - ) -> impl AsyncBounds + Future>>; + cb: impl FnOnce(&dyn Request) -> bool, + ) -> impl Future>>; } /// Initial negotiation sent by a client to start a WebSocket connection. @@ -31,8 +30,7 @@ pub trait WebSocketConnect { /// Initial negotiation sent by a client to start a WebSocket connection. fn connect( self, - ) -> impl AsyncBounds - + Future)>>; + ) -> impl Future)>>; } /// Necessary to decode incoming bytes of responses or requests. diff --git a/wtx/src/web_socket/handshake/raw.rs b/wtx/src/web_socket/handshake/raw.rs index 3d19a5ec..125c7a38 100644 --- a/wtx/src/web_socket/handshake/raw.rs +++ b/wtx/src/web_socket/handshake/raw.rs @@ -41,7 +41,7 @@ pub struct WebSocketConnectRaw<'fb, 'hb, 'uri, B, C, H, RNG, S, WSB> { mod httparse_impls { use crate::{ http::{ExpectedHeader, Header as _, Request as _}, - misc::{AsyncBounds, FilledBufferWriter, Stream, UriRef}, + misc::{FilledBufferWriter, Stream, UriRef}, rng::Rng, web_socket::{ compression::NegotiatedCompression, @@ -63,16 +63,15 @@ mod httparse_impls { impl WebSocketAccept for WebSocketAcceptRaw where - C: AsyncBounds + Compression, - C::NegotiatedCompression: AsyncBounds, - RNG: AsyncBounds + Rng, - S: AsyncBounds + Stream, - WSB: AsyncBounds + BorrowMut, + C: Compression, + RNG: Rng, + S: Stream, + WSB: BorrowMut, { #[inline] async fn accept( mut self, - cb: impl AsyncBounds + FnOnce(&dyn crate::http::Request) -> bool, + cb: impl FnOnce(&dyn crate::http::Request) -> bool, ) -> crate::Result> { let nb = &mut self.wsb.borrow_mut().nb; nb._set_indices_through_expansion(0, 0, MAX_READ_LEN); @@ -132,12 +131,11 @@ mod httparse_impls { impl<'fb, 'hb, B, C, RNG, S, WSB> WebSocketConnect for WebSocketConnectRaw<'fb, 'hb, '_, B, C, Header<'fb>, RNG, S, WSB> where - B: AsyncBounds + AsMut<[u8]> + AsMut> + AsRef<[u8]>, - C: AsyncBounds + Compression, - C::NegotiatedCompression: AsyncBounds, - RNG: AsyncBounds + Rng, - S: AsyncBounds + Stream, - WSB: AsyncBounds + BorrowMut, + B: AsMut<[u8]> + AsMut> + AsRef<[u8]>, + C: Compression, + RNG: Rng, + S: Stream, + WSB: BorrowMut, 'fb: 'hb, { type Response = Response<'hb, 'fb>;