taler-rust

GNU Taler code in Rust. Largely core banking integrations.
Log | Files | Refs | Submodules | README | LICENSE

commit 03b336f51b2c04ae357f426b4b62ca7d8fcb56c8
parent fe2d3cb9080ca9c9548591e2829a7e8faaeacc6a
Author: Antoine A <>
Date:   Fri, 27 Mar 2026 11:45:15 +0100

common: more async closure

Diffstat:
Mcommon/taler-api/tests/api.rs | 2+-
Mcommon/taler-common/src/lib.rs | 6+++---
Mcommon/taler-test-utils/src/routine.rs | 29+++++++++++++----------------
Mtaler-cyclos/src/api.rs | 2+-
Mtaler-magnet-bank/src/api.rs | 2+-
5 files changed, 19 insertions(+), 22 deletions(-)

diff --git a/common/taler-api/tests/api.rs b/common/taler-api/tests/api.rs @@ -81,7 +81,7 @@ async fn transfer() { #[tokio::test] async fn outgoing_history() { let (server, _) = setup().await; - routine_pagination::<OutgoingHistory, _>( + routine_pagination::<OutgoingHistory>( &server, "/taler-wire-gateway/history/outgoing", async |i| { diff --git a/common/taler-common/src/lib.rs b/common/taler-common/src/lib.rs @@ -14,7 +14,7 @@ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ -use std::{future::Future, path::PathBuf, time::Duration}; +use std::{path::PathBuf, time::Duration}; use config::{Config, parser::ConfigSource}; use tracing::error; @@ -49,10 +49,10 @@ pub struct CommonArgs { log: Option<tracing::Level>, } -pub fn taler_main<F: Future<Output = Result<(), anyhow::Error>>>( +pub fn taler_main( src: ConfigSource, args: CommonArgs, - app: impl FnOnce(Config) -> F, + app: impl AsyncFnOnce(Config) -> Result<(), anyhow::Error>, ) { taler_logger(args.log).init(); let cfg = match Config::from_file(src, args.config) { diff --git a/common/taler-test-utils/src/routine.rs b/common/taler-test-utils/src/routine.rs @@ -98,10 +98,10 @@ pub async fn latest_id<T: Page>(router: &Router, url: &str) -> i64 { } } -pub async fn routine_pagination<T: Page, F: Future<Output = ()>>( +pub async fn routine_pagination<T: Page>( server: &Router, url: &str, - mut register: impl FnMut(usize) -> F, + mut register: impl AsyncFnMut(usize) -> (), ) { // Check supported if !server.get(url).await.is_implemented() { @@ -145,10 +145,10 @@ async fn assert_time<R: Debug>(range: std::ops::Range<u128>, task: impl Future<O } } -async fn check_history_trigger<T: Page, F: Future<Output = ()>>( +async fn check_history_trigger<T: Page>( server: &Router, url: &str, - lambda: impl FnOnce() -> F, + lambda: impl AsyncFnOnce() -> (), ) { // Check history is following specs macro_rules! assert_history { @@ -186,11 +186,8 @@ async fn check_history_trigger<T: Page, F: Future<Output = ()>>( ); } -async fn check_history_in_trigger<F: Future<Output = ()>>( - server: &Router, - lambda: impl FnOnce() -> F, -) { - check_history_trigger::<IncomingHistory, _>( +async fn check_history_in_trigger(server: &Router, lambda: impl AsyncFnOnce() -> ()) { + check_history_trigger::<IncomingHistory>( server, "/taler-wire-gateway/history/incoming", lambda, @@ -198,13 +195,13 @@ async fn check_history_in_trigger<F: Future<Output = ()>>( .await; } -pub async fn routine_history<T: Page, FR: Future<Output = ()>, FI: Future<Output = ()>>( +pub async fn routine_history<T: Page>( server: &Router, url: &str, nb_register: usize, - mut register: impl FnMut(usize) -> FR, + mut register: impl AsyncFnMut(usize) -> (), nb_ignore: usize, - mut ignore: impl FnMut(usize) -> FI, + mut ignore: impl AsyncFnMut(usize) -> (), ) { // Check history is following specs macro_rules! assert_history { @@ -315,7 +312,7 @@ pub async fn routine_history<T: Page, FR: Future<Output = ()>, FI: Future<Output } ); - routine_pagination::<T, _>(server, url, register).await; + routine_pagination::<T>(server, url, register).await; } impl TestResponse { @@ -547,7 +544,7 @@ pub async fn transfer_routine( } // Pagination test - routine_pagination::<TransferList, _>(server, "/taler-wire-gateway/transfers", async |i| { + routine_pagination::<TransferList>(server, "/taler-wire-gateway/transfers", async |i| { server .post("/taler-wire-gateway/transfer") .json(&json!({ @@ -642,7 +639,7 @@ async fn add_incoming_routine( pub async fn revenue_routine(server: &Router, debit_acount: &PaytoURI, kyc: bool) { let currency = &get_wire_currency(server).await; - routine_history::<RevenueIncomingHistory, _, _>( + routine_history::<RevenueIncomingHistory>( server, "/taler-revenue/history", 2, @@ -681,7 +678,7 @@ pub async fn admin_add_incoming_routine(server: &Router, debit_acount: &PaytoURI // History // TODO check non taler some are ignored - routine_history::<IncomingHistory, _, _>( + routine_history::<IncomingHistory>( server, "/taler-wire-gateway/history/incoming", 2, diff --git a/taler-cyclos/src/api.rs b/taler-cyclos/src/api.rs @@ -387,7 +387,7 @@ mod test { #[tokio::test] async fn outgoing_history() { let (server, pool) = setup().await; - routine_pagination::<OutgoingHistory, _>( + routine_pagination::<OutgoingHistory>( &server, "/taler-wire-gateway/history/outgoing", async |i| { diff --git a/taler-magnet-bank/src/api.rs b/taler-magnet-bank/src/api.rs @@ -361,7 +361,7 @@ mod test { #[tokio::test] async fn outgoing_history() { let (server, pool) = setup().await; - routine_pagination::<OutgoingHistory, _>( + routine_pagination::<OutgoingHistory>( &server, "/taler-wire-gateway/history/outgoing", async |i| {