Skip to main content

iota_sdk_graphql_client/api/
mod.rs

1// Copyright (c) Mysten Labs, Inc.
2// Modifications Copyright (c) 2026 IOTA Stiftung
3// SPDX-License-Identifier: Apache-2.0
4
5//! API implementations for the GraphQL client.
6
7pub(crate) mod balance;
8pub(crate) mod checkpoints;
9pub(crate) mod coins;
10pub(crate) mod dry_run;
11pub(crate) mod dynamic_fields;
12pub(crate) mod epochs;
13pub(crate) mod events;
14pub(crate) mod iota_names;
15#[cfg(feature = "move-types")]
16pub(crate) mod move_objects;
17pub(crate) mod move_view_call;
18pub(crate) mod network;
19pub(crate) mod objects;
20pub(crate) mod package;
21pub(crate) mod transactions;
22
23#[cfg(not(target_arch = "wasm32"))]
24pub(crate) type QueryFuture<T> = futures::future::BoxFuture<'static, T>;
25// The HTTP client's futures are not `Send` on wasm32.
26#[cfg(target_arch = "wasm32")]
27pub(crate) type QueryFuture<T> = futures::future::LocalBoxFuture<'static, T>;
28
29/// Generate a query object: a struct that runs its query when awaited.
30///
31/// The struct's [`IntoFuture`](std::future::IntoFuture) boxes the future of
32/// `send(self) -> $output`, which each invocation writes by hand in an
33/// inherent impl.
34macro_rules! define_query {
35    (
36        $(#[$meta:meta])*
37        pub struct $name:ident $(<$generic:ident: $bound:path>)? {
38            $($field:ident: $field_ty:ty),* $(,)?
39        }
40        output: $output:ty;
41    ) => {
42        $(#[$meta])*
43        #[must_use]
44        pub struct $name $(<$generic>)? {
45            $($field: $field_ty,)*
46        }
47
48        impl $(<$generic: $bound + 'static>)? ::std::future::IntoFuture for $name $(<$generic>)? {
49            type Output = $output;
50            type IntoFuture = $crate::api::QueryFuture<Self::Output>;
51
52            fn into_future(self) -> Self::IntoFuture {
53                Box::pin(self.send())
54            }
55        }
56    };
57}
58
59pub(crate) use define_query;