File tree 6 files changed +47
-16
lines changed 6 files changed +47
-16
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,6 @@ async fn main() -> monzo::Result<()> {
23
23
. transactions ( account_id)
24
24
. since ( Utc :: now ( ) - Duration :: try_days ( args. days ) . unwrap ( ) )
25
25
. limit ( args. limit )
26
- . send ( )
27
26
. await ?;
28
27
29
28
println ! ( "account: {account_id}" ) ;
Original file line number Diff line number Diff line change @@ -184,7 +184,6 @@ where
184
184
/// client
185
185
/// .basic_feed_item(account_id, title, image_url)
186
186
/// .body("i figured out how to send messages to monzo from my computer...")
187
- /// .send()
188
187
/// .await?;
189
188
/// #
190
189
/// # Ok(())
@@ -243,7 +242,6 @@ where
243
242
/// .transactions(account_id)
244
243
/// .since(Utc::now() - Duration::days(10))
245
244
/// .limit(10)
246
- /// .send()
247
245
/// .await?;
248
246
/// #
249
247
/// # Ok(())
@@ -270,7 +268,7 @@ where
270
268
/// #
271
269
/// let transaction_id = "TRANSACTION_ID";
272
270
///
273
- /// let transactions = client.transaction(transaction_id).send(). await?;
271
+ /// let transactions = client.transaction(transaction_id).await?;
274
272
/// #
275
273
/// # Ok(())
276
274
/// # }
Original file line number Diff line number Diff line change 3
3
pub use basic:: Request as Basic ;
4
4
5
5
pub ( crate ) mod basic {
6
+ use std:: future:: { Future , IntoFuture } ;
7
+
6
8
use serde:: Serialize ;
7
9
8
10
use crate :: { client, endpoints:: Endpoint , Result } ;
@@ -99,11 +101,6 @@ pub(crate) mod basic {
99
101
self . payload . params . body = Some ( body) ;
100
102
self
101
103
}
102
-
103
- /// Consume and send the [`Request`].
104
- pub async fn send ( self ) -> Result < ( ) > {
105
- self . client . handle_request ( & self ) . await
106
- }
107
104
}
108
105
109
106
impl < C > Endpoint for Request < ' _ , C >
@@ -121,6 +118,20 @@ pub(crate) mod basic {
121
118
}
122
119
}
123
120
121
+ impl < ' a , C > IntoFuture for Request < ' a , C >
122
+ where
123
+ C : client:: Inner ,
124
+ {
125
+ type Output = Result < ( ) > ;
126
+
127
+ type IntoFuture = impl Future < Output = Self :: Output > ;
128
+
129
+ /// Consume and send the [`Request`].
130
+ fn into_future ( self ) -> Self :: IntoFuture {
131
+ async move { self . client . handle_request ( & self ) . await }
132
+ }
133
+ }
134
+
124
135
#[ derive( Debug , Serialize ) ]
125
136
struct Params < ' a > {
126
137
#[ serde( rename = "params[title]" ) ]
Original file line number Diff line number Diff line change
1
+ use std:: future:: { Future , IntoFuture } ;
2
+
1
3
use super :: Transaction ;
2
4
use crate :: { client, endpoints:: Endpoint , Result } ;
3
5
53
55
self . expand_merchant = true ;
54
56
self
55
57
}
58
+ }
59
+
60
+ impl < ' a , C > IntoFuture for Request < ' a , C >
61
+ where
62
+ C : client:: Inner ,
63
+ {
64
+ type Output = Result < Transaction > ;
65
+
66
+ type IntoFuture = impl Future < Output = Self :: Output > ;
56
67
57
68
/// Consume the request and return the [`Transaction`]
58
- pub async fn send ( self ) -> Result < Transaction > {
59
- self . client . handle_request ( & self ) . await
69
+ fn into_future ( self ) -> Self :: IntoFuture {
70
+ async move { self . client . handle_request ( & self ) . await }
60
71
}
61
72
}
Original file line number Diff line number Diff line change
1
+ use std:: future:: { Future , IntoFuture } ;
2
+
1
3
use chrono:: { DateTime , Utc } ;
2
4
use serde:: { Deserialize , Serialize } ;
3
5
@@ -78,17 +80,26 @@ where
78
80
self . query . expand_merchant = Some ( "merchant" ) ;
79
81
self
80
82
}
83
+ }
84
+
85
+ impl < ' a , C > IntoFuture for Request < ' a , C >
86
+ where
87
+ C : client:: Inner ,
88
+ {
89
+ type Output = Result < Vec < Transaction > > ;
90
+
91
+ type IntoFuture = impl Future < Output = Self :: Output > ;
81
92
82
93
/// Consume the request and return the list of [`Transaction`]s
83
- pub async fn send ( self ) -> Result < Vec < Transaction > > {
94
+ fn into_future ( self ) -> Self :: IntoFuture {
84
95
#[ derive( Deserialize ) ]
85
96
struct Response {
86
97
transactions : Vec < Transaction > ,
87
98
}
88
-
89
- let response: Response = self . client . handle_request ( & self ) . await ?;
90
-
91
- Ok ( response . transactions )
99
+ async move {
100
+ let response: Response = self . client . handle_request ( & self ) . await ?;
101
+ Ok ( response . transactions )
102
+ }
92
103
}
93
104
}
94
105
Original file line number Diff line number Diff line change 7
7
) ]
8
8
#![ warn( clippy:: pedantic) ]
9
9
#![ allow( clippy:: missing_errors_doc) ]
10
+ #![ feature( impl_trait_in_assoc_type) ]
10
11
11
12
//! A Monzo client in pure rust.
12
13
//!
You can’t perform that action at this time.
0 commit comments