diff options
author | David Blajda <blajda@hotmail.com> | 2018-12-16 19:31:45 +0000 |
---|---|---|
committer | David Blajda <blajda@hotmail.com> | 2018-12-16 19:31:45 +0000 |
commit | be68a7da226743edbce5b52e506d9083e2859578 (patch) | |
tree | bd0a04bf63637d2392495c06d65bdc242be15f6b /src/bin | |
parent | 136f56e2d9a010ea76041ba6b44873491ddef848 (diff) |
Prototype of a trait based client
Diffstat (limited to 'src/bin')
-rw-r--r-- | src/bin/main.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/bin/main.rs b/src/bin/main.rs index 7fdde47..45b25df 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -8,12 +8,15 @@ use futures::future::Future; use std::env; use twitch_api::Client; +use twitch_api::helix::HelixClient; + fn main() { dotenv::dotenv().unwrap(); let client_id = &env::var("TWITCH_API").unwrap(); let client = Client::new(client_id); - let clip = client.helix + + let clip = client.helix.clips() .clip(&"EnergeticApatheticTarsierThisIsSparta") .map_err(|err| { println!("{:?}", err); @@ -27,13 +30,19 @@ fn main() { () }); + /* Prevents tokio from **hanging** + * since tokio::run blocks the current thread and waits for the entire runtime + * to become idle but it will never becomes idle since we keep a reference + * to a reqwest client which maintains a connection pool. + */ + std::mem::drop(client); tokio::run( clip.join(clip2) .and_then(|(c1, c2)| { println!("{:?} {:?}", c1, c2); Ok((c1, c2)) }) - .map(|_| { client.nop(); ()}) + .map(|_| ()) .map_err(|_| ()) ); } |