agent-rs
agent-rs copied to clipboard
I can’t add rust agent to my wasn?
When I add
[dependencies]
ic-agent = "0.20.0"
To Cargo.toml
I got this error
Consider changing their names to be unique or compiling them separately.
This may become a hard error in the future; see <https://github.com/rust-lang/cargo/issues/6313>.
error[E0583]: file not found for module `sys`
--> /Users/apple/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.7/src/lib.rs:124:1
|
124 | mod sys;
| ^^^^^^^^
|
= help: to create the module `sys`, create file "/Users/apple/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.7/src/sys.rs" or "/Users/apple/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.7/src/sys/mod.rs"
I tride older versions but nothing
Correct. The agent is for client-side code (and for browsers, js-sys support has not been added yet). For canisters you would use ic_cdk::call
, and for browsers you would use agent-js.
I tried using it but what is the ArgumentEncoder
??
async move {
let greeting = call(principal, "greet", ("Ali")).await.unwrap();
};
error
27 | let greeting = call(principal, "greet", ("Ali")).await.unwrap();
| ---- ^^^^^^^ the trait `ArgumentEncoder` is not implemented for `&str`
Add a comma: ("Ali",)
Otherwise ("Ali")
is the same thing as writing "Ali"
.
Wanted to clarify, does this mean that agent-rs won't work for a Rust application that's compiled to WASM and runs in the browser?
Correct. This is a feature in our backlog, but for now, if you wanted to interact with the IC from browser wasm, your best bet is agent-js through wasm_bindgen.
Closing as the stated issue is intended behavior.