Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion examples/list_transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ async fn main() -> monzo::Result<()> {
.transactions(account_id)
.since(Utc::now() - Duration::try_days(args.days).unwrap())
.limit(args.limit)
.send()
.await?;

println!("account: {account_id}");
Expand Down
4 changes: 1 addition & 3 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ where
/// client
/// .basic_feed_item(account_id, title, image_url)
/// .body("i figured out how to send messages to monzo from my computer...")
/// .send()
/// .await?;
/// #
/// # Ok(())
Expand Down Expand Up @@ -242,7 +241,6 @@ where
/// .transactions(account_id)
/// .since(Utc::now() - Duration::days(10))
/// .limit(10)
/// .send()
/// .await?;
/// #
/// # Ok(())
Expand All @@ -269,7 +267,7 @@ where
/// #
/// let transaction_id = "TRANSACTION_ID";
///
/// let transactions = client.transaction(transaction_id).send().await?;
/// let transactions = client.transaction(transaction_id).await?;
/// #
/// # Ok(())
/// # }
Expand Down
21 changes: 16 additions & 5 deletions src/endpoints/feed_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
pub use basic::Request as Basic;

pub(crate) mod basic {
use std::future::{Future, IntoFuture};

use serde::Serialize;

use crate::{client, endpoints::Endpoint, Result};
Expand Down Expand Up @@ -99,11 +101,6 @@
self.payload.params.body = Some(body);
self
}

/// Consume and send the [`Request`].
pub async fn send(self) -> Result<()> {
self.client.handle_request(&self).await
}
}

impl<C> Endpoint for Request<'_, C>
Expand All @@ -121,6 +118,20 @@
}
}

impl<'a, C> IntoFuture for Request<'a, C>
where
C: client::Inner,
{
type Output = Result<()>;

type IntoFuture = impl Future<Output = Self::Output>;

Check failure on line 127 in src/endpoints/feed_items.rs

View workflow job for this annotation

GitHub Actions / lint

`impl Trait` in associated types is unstable

error[E0658]: `impl Trait` in associated types is unstable --> src/endpoints/feed_items.rs:127:27 | 127 | type IntoFuture = impl Future<Output = Self::Output>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information = help: add `#![feature(impl_trait_in_assoc_type)]` to the crate attributes to enable = note: this compiler was built on 2025-12-02; consider upgrading it if it is out of date

/// Consume and send the [`Request`].
fn into_future(self) -> Self::IntoFuture {
async move { self.client.handle_request(&self).await }
}
}

#[derive(Debug, Serialize)]
struct Params<'a> {
#[serde(rename = "params[title]")]
Expand Down
15 changes: 13 additions & 2 deletions src/endpoints/transactions/get.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::future::{Future, IntoFuture};

use super::Transaction;
use crate::{client, endpoints::Endpoint, Result};

Expand Down Expand Up @@ -53,9 +55,18 @@
self.expand_merchant = true;
self
}
}

impl<'a, C> IntoFuture for Request<'a, C>
where
C: client::Inner,
{
type Output = Result<Transaction>;

type IntoFuture = impl Future<Output = Self::Output>;

Check failure on line 66 in src/endpoints/transactions/get.rs

View workflow job for this annotation

GitHub Actions / lint

`impl Trait` in associated types is unstable

error[E0658]: `impl Trait` in associated types is unstable --> src/endpoints/transactions/get.rs:66:23 | 66 | type IntoFuture = impl Future<Output = Self::Output>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information = help: add `#![feature(impl_trait_in_assoc_type)]` to the crate attributes to enable = note: this compiler was built on 2025-12-02; consider upgrading it if it is out of date

/// Consume the request and return the [`Transaction`]
pub async fn send(self) -> Result<Transaction> {
self.client.handle_request(&self).await
fn into_future(self) -> Self::IntoFuture {
async move { self.client.handle_request(&self).await }
}
}
21 changes: 16 additions & 5 deletions src/endpoints/transactions/list.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::future::{Future, IntoFuture};

use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -78,17 +80,26 @@
self.query.expand_merchant = Some("merchant");
self
}
}

impl<'a, C> IntoFuture for Request<'a, C>
where
C: client::Inner,
{
type Output = Result<Vec<Transaction>>;

type IntoFuture = impl Future<Output = Self::Output>;

Check failure on line 91 in src/endpoints/transactions/list.rs

View workflow job for this annotation

GitHub Actions / lint

`impl Trait` in associated types is unstable

error[E0658]: `impl Trait` in associated types is unstable --> src/endpoints/transactions/list.rs:91:23 | 91 | type IntoFuture = impl Future<Output = Self::Output>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information = help: add `#![feature(impl_trait_in_assoc_type)]` to the crate attributes to enable = note: this compiler was built on 2025-12-02; consider upgrading it if it is out of date

/// Consume the request and return the list of [`Transaction`]s
pub async fn send(self) -> Result<Vec<Transaction>> {
fn into_future(self) -> Self::IntoFuture {
#[derive(Deserialize)]
struct Response {
transactions: Vec<Transaction>,
}

let response: Response = self.client.handle_request(&self).await?;

Ok(response.transactions)
async move {
let response: Response = self.client.handle_request(&self).await?;
Ok(response.transactions)
}
}
}

Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#![warn(clippy::pedantic)]
#![warn(clippy::nursery)]
#![allow(clippy::missing_errors_doc)]

#![doc = include_str!("../README.md")]

mod client;
Expand Down
Loading