canic_core/dispatch/
mod.rs1pub mod icrc21;
2
3use crate::{api::EndpointCall, perf};
4use std::future::Future;
5
6pub fn dispatch_query<R>(call: EndpointCall, f: impl FnOnce() -> R) -> R {
8 perf::enter_endpoint();
9 let res = f();
10 perf::exit_endpoint(call);
11
12 res
13}
14
15pub async fn dispatch_query_async<R, F>(call: EndpointCall, f: impl FnOnce() -> F) -> R
17where
18 F: Future<Output = R>,
19{
20 perf::enter_endpoint();
21 let res = f().await;
22 perf::exit_endpoint(call);
23
24 res
25}
26
27pub fn dispatch_update<R>(call: EndpointCall, f: impl FnOnce() -> R) -> R {
29 perf::enter_endpoint();
30 let res = f();
31 perf::exit_endpoint(call);
32
33 res
34}
35
36pub async fn dispatch_update_async<R, F>(call: EndpointCall, f: impl FnOnce() -> F) -> R
38where
39 F: Future<Output = R>,
40{
41 perf::enter_endpoint();
42 let res = f().await;
43 perf::exit_endpoint(call);
44
45 res
46}