danieleades / monzo-lib

monzo API client library, in pure rust
16 stars 4 forks source link

make use of IntoFuture and 'Async Builder' pattern #2

Closed danieleades closed 4 years ago

danieleades commented 5 years ago

The ergonomics of this crate can be improved when IntoFuture is merged (see this issue) by using the 'async builder pattern' (see this blog post).

This would allow dropping the send() method on requests and simply awaiting them directly

from

let transactions = client.transactions(account_id)
    .send()
    .await?;

to

let transactions = client.transactions(account_id)
    .await?;

This is a minor papercut, but would be pretty slick.

This could be done today by implementing Future for each request. I did that that in an earlier version, but the cost in terms of code complexity and readability were not worth it

danieleades commented 4 years ago

done