From 1ff136177d2d5244ff80ba1f435d6e04c7ea50d8 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Mon, 12 Feb 2024 11:16:23 +0200 Subject: [PATCH] add ping and example --- solar_client/examples/ping.rs | 15 +++++++++++++++ solar_client/src/lib.rs | 2 ++ 2 files changed, 17 insertions(+) create mode 100644 solar_client/examples/ping.rs diff --git a/solar_client/examples/ping.rs b/solar_client/examples/ping.rs new file mode 100644 index 0000000..216e4d1 --- /dev/null +++ b/solar_client/examples/ping.rs @@ -0,0 +1,15 @@ +use anyhow::Result; +use solar_client::{Client, SolarClient}; + +const SERVER_ADDR: &str = "http://127.0.0.1:3030"; + +#[tokio::main] +async fn main() -> Result<()> { + let client = Client::new(SERVER_ADDR.to_owned())?; + + let ping = client.ping().await?; + println!("{}", ping); + // pong! + + Ok(()) +} diff --git a/solar_client/src/lib.rs b/solar_client/src/lib.rs index 20b5743..880c630 100644 --- a/solar_client/src/lib.rs +++ b/solar_client/src/lib.rs @@ -2,6 +2,8 @@ use anyhow::Result; #[jsonrpc_client::api] pub trait SolarClient { + async fn ping(&self) -> String; + async fn whoami(&self) -> String; }