From b5964484ca1747d1a7078c3ac9114fb86a5a45da Mon Sep 17 00:00:00 2001 From: FireMasterK <20838718+FireMasterK@users.noreply.github.com> Date: Thu, 29 Apr 2021 22:04:00 +0530 Subject: [PATCH] Add trending example. --- examples/Cargo.toml | 4 ++++ examples/trending.rs | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 examples/trending.rs diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 8712f69..9b52963 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -12,3 +12,7 @@ tokio = {version = "1.5.0", features = ["macros", "rt-multi-thread"]} [[example]] name = "channel" path = "channel.rs" + +[[example]] +name = "trending" +path = "trending.rs" diff --git a/examples/trending.rs b/examples/trending.rs new file mode 100644 index 0000000..7806a45 --- /dev/null +++ b/examples/trending.rs @@ -0,0 +1,18 @@ +use piped::piped::PipedClient; +use reqwest::ClientBuilder; + +#[tokio::main] +async fn main() { + let httpclient = ClientBuilder::new() + .user_agent("Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Firefox/78.0") + .build() + .unwrap(); + + let instance = "https://pipedapi.kavin.rocks".to_string(); + + let client = PipedClient::new(httpclient, instance); + + let channel = client.get_trending().await.unwrap(); + + println!("{:?}", channel); +}