Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: no more tuples in Call #539

Merged
merged 9 commits into from
Dec 16, 2024
Merged

feat: no more tuples in Call #539

merged 9 commits into from
Dec 16, 2024

Conversation

lwshang
Copy link
Contributor

@lwshang lwshang commented Dec 14, 2024

Description

Many Rust Canister developers (including myself) have some complaints about the inter-canister call syntax:

It's quite annoying that the arguments to calls and their results have to be written as singleton tuples in order for ArgumentEncoder and ArgumentDecoder to be derived for types that implement CandidType

The new Call type fixes it!

Say canister "abcde-xxxxx" has following Candid interface:

service : {
    echo : (u32) -> (u32);
}

Before, we have to put both args and returns in singleton tuples:

let res: (u32,) = call("abcde-xxxxx", "echo", (1u32,)).await().unwrap();

Now, we can:

let res: u32 = Call::new("abcde-xxxxx", "echo").with_arg(1u32).call().await.unwrap();

How Has This Been Tested?

e2e-tests/tests/call.rs

Checklist:

  • The title of this PR complies with Conventional Commits.
  • I have edited the CHANGELOG accordingly.
  • I have made corresponding changes to the documentation.

@lwshang lwshang marked this pull request as ready for review December 14, 2024 02:30
@lwshang lwshang requested a review from a team as a code owner December 14, 2024 02:30
@lwshang lwshang merged commit d98a6ff into next Dec 16, 2024
9 checks passed
@lwshang lwshang deleted the lwshang/refine_call branch December 16, 2024 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant