Skip to content

Instantly share code, notes, and snippets.

@folex
Created July 1, 2021 16:37
Show Gist options
  • Save folex/4bae5b8839fba2306ee906f7add921a7 to your computer and use it in GitHub Desktop.
Save folex/4bae5b8839fba2306ee906f7add921a7 to your computer and use it in GitHub Desktop.
Use Fluence from Rust with ConnectedClient crate
[package]
name = "concl"
version = "0.1.0"
edition = "2018"
[dependencies]
connected-client = { git = "https://github.com/fluencelabs/fluence" }
eyre = "0.6.5"
maplit = "1.0.2"
serde_json = "1.0.64"
use connected_client::ConnectedClient;
use eyre::Result;
fn main() -> Result<()> {
let mut client: ConnectedClient = ConnectedClient::connect_to("/dns4/kras-00.fluence.dev/tcp/7770".parse()?)?;
let id = client.send_particle(
r#"
(seq
(call relay ("op" "noop") [])
(call %init_peer_id% ("callbackSrv" "response") ["hey"])
)
"#,
maplit::hashmap! {
"relay" => serde_json::json!(client.node.to_string())
}
);
println!("particle id: {}", id);
let answer = client.wait_particle_args(id)?;
println!("got answer: {:?}", answer);
Ok(())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment