@@ -9,12 +9,12 @@ use std::{
99 convert:: TryFrom ,
1010 error:: Error ,
1111 fmt:: { self , Debug , Display , Formatter } ,
12+ future:: Future ,
1213 time:: { SystemTime , SystemTimeError } ,
1314} ;
1415#[ cfg( feature = "metrics" ) ]
1516use std:: { sync:: LazyLock , time:: Instant } ;
1617
17- use async_trait:: async_trait;
1818use base64:: { Engine , engine:: general_purpose:: STANDARD as BASE64_ENGINE } ;
1919use bytes:: Buf ;
2020use crypto_common:: InvalidLength ;
@@ -65,58 +65,69 @@ static CLIENT_REQUEST_DURATION: LazyLock<CounterVec> = LazyLock::new(|| {
6565
6666// -----------------------------------------------------------------------------
6767// Types
68+
6869type HmacSha512 = Hmac < Sha512 > ;
6970
7071// -----------------------------------------------------------------------------
7172// Request trait
7273
73- #[ async_trait]
7474pub trait Request {
7575 type Error ;
7676
77- async fn request < T , U > (
77+ fn request < T , U > (
7878 & self ,
7979 method : & Method ,
8080 endpoint : & str ,
8181 payload : & T ,
82- ) -> Result < U , Self :: Error >
82+ ) -> impl Future < Output = Result < U , Self :: Error > > + Send
8383 where
8484 T : Serialize + Debug + Send + Sync ,
8585 U : DeserializeOwned + Debug + Send + Sync ;
8686
87- async fn execute ( & self , request : reqwest:: Request ) -> Result < reqwest:: Response , Self :: Error > ;
87+ fn execute (
88+ & self ,
89+ request : reqwest:: Request ,
90+ ) -> impl Future < Output = Result < reqwest:: Response , Self :: Error > > + Send ;
8891}
8992
9093// -----------------------------------------------------------------------------
9194// RestClient trait
9295
93- #[ async_trait]
94- pub trait RestClient
95- where
96- Self : Debug ,
97- {
96+ pub trait RestClient : Debug {
9897 type Error ;
9998
100- async fn get < T > ( & self , endpoint : & str ) -> Result < T , Self :: Error >
99+ fn get < T > ( & self , endpoint : & str ) -> impl Future < Output = Result < T , Self :: Error > > + Send
101100 where
102101 T : DeserializeOwned + Debug + Send + Sync ;
103102
104- async fn post < T , U > ( & self , endpoint : & str , payload : & T ) -> Result < U , Self :: Error >
103+ fn post < T , U > (
104+ & self ,
105+ endpoint : & str ,
106+ payload : & T ,
107+ ) -> impl Future < Output = Result < U , Self :: Error > > + Send
105108 where
106109 T : Serialize + Debug + Send + Sync ,
107110 U : DeserializeOwned + Debug + Send + Sync ;
108111
109- async fn put < T , U > ( & self , endpoint : & str , payload : & T ) -> Result < U , Self :: Error >
112+ fn put < T , U > (
113+ & self ,
114+ endpoint : & str ,
115+ payload : & T ,
116+ ) -> impl Future < Output = Result < U , Self :: Error > > + Send
110117 where
111118 T : Serialize + Debug + Send + Sync ,
112119 U : DeserializeOwned + Debug + Send + Sync ;
113120
114- async fn patch < T , U > ( & self , endpoint : & str , payload : & T ) -> Result < U , Self :: Error >
121+ fn patch < T , U > (
122+ & self ,
123+ endpoint : & str ,
124+ payload : & T ,
125+ ) -> impl Future < Output = Result < U , Self :: Error > > + Send
115126 where
116127 T : Serialize + Debug + Send + Sync ,
117128 U : DeserializeOwned + Debug + Send + Sync ;
118129
119- async fn delete ( & self , endpoint : & str ) -> Result < ( ) , Self :: Error > ;
130+ fn delete ( & self , endpoint : & str ) -> impl Future < Output = Result < ( ) , Self :: Error > > + Send ;
120131}
121132
122133// -----------------------------------------------------------------------------
@@ -198,10 +209,7 @@ pub const OAUTH1_VERSION: &str = "oauth_version";
198209pub const OAUTH1_VERSION_1 : & str = "1.0" ;
199210pub const OAUTH1_TOKEN : & str = "oauth_token" ;
200211
201- pub trait OAuth1
202- where
203- Self : Debug ,
204- {
212+ pub trait OAuth1 : Debug {
205213 type Error ;
206214
207215 // `params` returns OAuth1 parameters without the signature one
@@ -432,7 +440,6 @@ pub struct Client {
432440 credentials : Option < Credentials > ,
433441}
434442
435- #[ async_trait]
436443impl Request for Client {
437444 type Error = ClientError ;
438445
@@ -491,7 +498,7 @@ impl Request for Client {
491498 ) ) ;
492499 }
493500
494- Ok ( serde_json:: from_reader ( buf. reader ( ) ) . map_err ( ClientError :: Deserialize ) ? )
501+ serde_json:: from_reader ( buf. reader ( ) ) . map_err ( ClientError :: Deserialize )
495502 }
496503
497504 #[ cfg_attr( feature = "tracing" , tracing:: instrument) ]
@@ -566,7 +573,6 @@ impl Request for Client {
566573 }
567574}
568575
569- #[ async_trait]
570576impl RestClient for Client {
571577 type Error = ClientError ;
572578
@@ -597,7 +603,7 @@ impl RestClient for Client {
597603 ) ) ;
598604 }
599605
600- Ok ( serde_json:: from_reader ( buf. reader ( ) ) . map_err ( ClientError :: Deserialize ) ? )
606+ serde_json:: from_reader ( buf. reader ( ) ) . map_err ( ClientError :: Deserialize )
601607 }
602608
603609 #[ cfg_attr( feature = "tracing" , tracing:: instrument) ]
0 commit comments