From 7d79e9886ee62f3dd01db625ff9def7d34fe0f04 Mon Sep 17 00:00:00 2001 From: Sebastian Rollen Date: Fri, 5 Nov 2021 10:05:48 -0400 Subject: [PATCH] fix: upgrade rest-client such that lifetimes are no longer needed --- Cargo.toml | 2 +- src/rest/mod.rs | 2 +- src/rest/stocks.rs | 23 ++++++++++------------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3d8248d..0b1161a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ edition = "2018" chrono = { version = "0.4", features = ["serde"] } futures = { version = "0.3"} itertools = "0.10" -rest-client = {git = "ssh://git@github.com/Overmuse/rest-client.git", tag = "v0.1.1", optional = true} +rest-client = {git = "ssh://git@github.com/Overmuse/rest-client.git", tag = "v0.1.2", optional = true} rust_decimal = { version = "1.11", features = ["serde-float"] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/src/rest/mod.rs b/src/rest/mod.rs index 41e2e87..01a3186 100644 --- a/src/rest/mod.rs +++ b/src/rest/mod.rs @@ -9,6 +9,6 @@ pub fn client(token: &str) -> Client { Client::new("https://api.polygon.io").query_auth(vec![("apiKey", token)]) } -pub fn client_with_url<'a>(url: &'a str, token: &'a str) -> Client<'a> { +pub fn client_with_url(url: &str, token: &str) -> Client { Client::new(url).query_auth(vec![("apiKey", token)]) } diff --git a/src/rest/stocks.rs b/src/rest/stocks.rs index 918a628..e042bce 100644 --- a/src/rest/stocks.rs +++ b/src/rest/stocks.rs @@ -106,21 +106,18 @@ impl<'a> Request for GetQuotes<'a> { } } -fn query_pagination( - _: &PaginationState, - res: &QuoteWrapper, -) -> Option> { - res.results.iter().last().map(|q| { - vec![( - "timestamp".to_string(), - format!("{}", q.t.timestamp_nanos()), - )] - }) -} - impl<'a> PaginatedRequest for GetQuotes<'a> { fn paginator(&self) -> Box> { - Box::new(QueryPaginator::new(query_pagination)) + Box::new(QueryPaginator::new( + |_: &PaginationState, res: &QuoteWrapper| { + res.results.iter().last().map(|q| { + vec![( + "timestamp".to_string(), + format!("{}", q.t.timestamp_nanos()), + )] + }) + }, + )) } }