1pub mod call;
2pub mod http;
3pub mod ledger;
4pub mod mgmt;
5pub mod network;
6pub mod signature;
7
8pub use crate::ops::ic::IcOps;
10
11use crate::{api::prelude::*, cdk::candid::CandidType, ops::ic::call::CallOps};
12use serde::de::DeserializeOwned;
13
14pub struct Call;
21
22impl Call {
23 #[must_use]
24 pub fn bounded_wait(canister_id: impl Into<Principal>, method: &str) -> CallBuilder {
25 CallBuilder {
26 inner: CallOps::bounded_wait(canister_id, method),
27 }
28 }
29
30 #[must_use]
31 pub fn unbounded_wait(canister_id: impl Into<Principal>, method: &str) -> CallBuilder {
32 CallBuilder {
33 inner: CallOps::unbounded_wait(canister_id, method),
34 }
35 }
36}
37
38pub struct CallBuilder {
43 inner: crate::ops::ic::call::CallBuilder,
44}
45
46impl CallBuilder {
47 pub fn try_with_arg<A: CandidType>(self, arg: A) -> Result<Self, PublicError> {
48 let inner = self.inner.try_with_arg(arg)?;
49
50 Ok(Self { inner })
51 }
52
53 #[must_use]
54 pub fn with_cycles(self, cycles: u128) -> Self {
55 Self {
56 inner: self.inner.with_cycles(cycles),
57 }
58 }
59
60 pub async fn execute(self) -> Result<CallResult, PublicError> {
61 let inner = self.inner.execute().await?;
62
63 Ok(CallResult { inner })
64 }
65}
66
67pub struct CallResult {
74 inner: crate::ops::ic::call::CallResult,
75}
76
77impl CallResult {
78 pub fn candid<R>(&self) -> Result<R, PublicError>
80 where
81 R: CandidType + DeserializeOwned,
82 {
83 self.inner.candid().map_err(PublicError::from)
84 }
85}