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/lib.rs | |
parent | 136f56e2d9a010ea76041ba6b44873491ddef848 (diff) |
Prototype of a trait based client
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 28 |
1 files changed, 23 insertions, 5 deletions
@@ -2,9 +2,7 @@ extern crate futures; extern crate reqwest; extern crate serde; extern crate chrono; - -#[macro_use] -extern crate serde_derive; +#[macro_use] extern crate serde_derive; pub mod helix; pub mod kraken; @@ -12,7 +10,12 @@ pub mod types; pub use self::helix::Client as HelixClient; pub use self::kraken::Client as KrakenClient; + use reqwest::r#async::Client as ReqwestClient; +use reqwest::header::HeaderMap; +use std::marker::PhantomData; +use std::sync::Arc; +use std::collections::BTreeMap; pub struct Client { pub helix: HelixClient, @@ -27,7 +30,22 @@ impl Client { kraken: KrakenClient::new_with_client(client_id, client.clone()), } } +} - pub fn nop(self) { - } +trait Request<T> { + fn url(&self) -> String; + fn headers(&self) -> &HeaderMap; + fn query(&self) -> &BTreeMap<String, String>; + fn returns(&self) -> T; +} + +pub struct GetRequest<T> { + inner: Arc<GetRequestRef<T>>, +} + +struct GetRequestRef<T> { + url: String, +// headers: HeaderMap, +// query: BTreeMap<String, String>, + returns: PhantomData<T>, } |