Skip to content

Commit

Permalink
fix: upgrade rest-client such that lifetimes are no longer needed
Browse files Browse the repository at this point in the history
  • Loading branch information
SebRollen committed Nov 5, 2021
1 parent 0b23b60 commit 7d79e98
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ edition = "2018"
chrono = { version = "0.4", features = ["serde"] }
futures = { version = "0.3"}
itertools = "0.10"
rest-client = {git = "ssh://[email protected]/Overmuse/rest-client.git", tag = "v0.1.1", optional = true}
rest-client = {git = "ssh://[email protected]/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"
Expand Down
2 changes: 1 addition & 1 deletion src/rest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)])
}
23 changes: 10 additions & 13 deletions src/rest/stocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,21 +106,18 @@ impl<'a> Request for GetQuotes<'a> {
}
}

fn query_pagination(
_: &PaginationState<PaginationType>,
res: &QuoteWrapper,
) -> Option<Vec<(String, String)>> {
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<dyn Paginator<QuoteWrapper>> {
Box::new(QueryPaginator::new(query_pagination))
Box::new(QueryPaginator::new(
|_: &PaginationState<PaginationType>, res: &QuoteWrapper| {
res.results.iter().last().map(|q| {
vec![(
"timestamp".to_string(),
format!("{}", q.t.timestamp_nanos()),
)]
})
},
))
}
}

Expand Down

0 comments on commit 7d79e98

Please sign in to comment.