When I have a Motoko function like:
public shared func f(x: Blob): async () {
...
}
and try to pass it Encode!(b)
from Rust, where b: &[u8]
, it complains about a wrong type.
How to pass blob
type to a Motoko method?
When I have a Motoko function like:
public shared func f(x: Blob): async () {
...
}
and try to pass it Encode!(b)
from Rust, where b: &[u8]
, it complains about a wrong type.
How to pass blob
type to a Motoko method?
Rust code
let req_id = agent.update(&callback.canister, &callback.func)
.with_arg(Encode!(&(*&actix_request_hash.as_slice(),))?).call().await;
and Motoko code
public shared func checkRequest(hash: Blob): async () {
I also tried
public shared func checkRequest(hash: [Nat8]): async () {
BTW, should I write &(*&actix_request_hash.as_slice(),)
or &actix_request_hash.as_slice()
suits?
A Blob
is a vector of bytes essentially, so in Rust it would be Vec<u8>
. I think the following code would work
let req_id = agent.update(&callback.canister, &callback.func)
.with_arg(Encode!(&(actix_request_hash,))?).call().await;