From cd42725ca5bffa1c5d4a0f4ee5107bd960c45e66 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Wed, 21 Feb 2024 08:49:24 +0200 Subject: [PATCH] add subscriptions and example --- solar_client/examples/subscriptions.rs | 27 ++++++++++++++++++++++++++ solar_client/src/lib.rs | 2 ++ 2 files changed, 29 insertions(+) create mode 100644 solar_client/examples/subscriptions.rs diff --git a/solar_client/examples/subscriptions.rs b/solar_client/examples/subscriptions.rs new file mode 100644 index 0000000..f2ad836 --- /dev/null +++ b/solar_client/examples/subscriptions.rs @@ -0,0 +1,27 @@ +use anyhow::Result; +use solar_client::{Client, SolarClient}; + +const SERVER_ADDR: &str = "http://127.0.0.1:3030"; +const PUB_KEY: &str = "@HEqy940T6uB+T+d9Jaa58aNfRzLx9eRWqkZljBmnkmk=.ed25519"; + +#[tokio::main] +async fn main() -> Result<()> { + let client = Client::new(SERVER_ADDR.to_owned())?; + + let subscriptions = client.subscriptions(PUB_KEY).await?; + println!("{:#?}", subscriptions); + // [ + // "falconry", + // "solarfest", + // "compendiumofmadscience", + // "inktober2018", + // "butt-summaries", + // "squatchcam", + // ... + // "arduino", + // "savingspools", + // "meditation", + // ] + + Ok(()) +} diff --git a/solar_client/src/lib.rs b/solar_client/src/lib.rs index d462bfa..bfa139a 100644 --- a/solar_client/src/lib.rs +++ b/solar_client/src/lib.rs @@ -50,6 +50,8 @@ pub trait SolarClient { async fn subscribers(&self, channel: &str) -> Vec; + async fn subscriptions(&self, pub_key: &str) -> Vec; + async fn whoami(&self) -> String; }