Use futures instead of tokio (for just one call, sounds more appropriate)

This commit is contained in:
VC
2020-05-19 22:33:19 +02:00
parent 1388f03837
commit 9809327784
3 changed files with 7 additions and 8 deletions

4
Cargo.lock generated
View File

@@ -1623,15 +1623,15 @@ dependencies = [
[[package]]
name = "scootaloo"
version = "0.2.0"
version = "0.2.1"
dependencies = [
"clap",
"egg-mode",
"elefren",
"futures 0.3.5",
"htmlescape",
"reqwest",
"serde",
"tokio 0.2.13",
"toml",
]

View File

@@ -1,6 +1,6 @@
[package]
name = "scootaloo"
version = "0.2.0"
version = "0.2.1"
authors = ["VC <veretcle+framagit@mateu.be>"]
edition = "2018"
@@ -11,7 +11,7 @@ serde = { version = "1.0", features = ["derive"] }
toml = "^0.5"
clap = "^2.33"
tokio = "^0.2"
futures = "^0.3"
egg-mode = "^0.14"
elefren = "^0.20"

View File

@@ -9,8 +9,8 @@ use std::{
error::Error,
};
//tokio
use tokio::runtime::Runtime;
// futures
use futures::executor::block_on;
// toml
use serde::Deserialize;
@@ -77,8 +77,7 @@ fn get_oauth2_token(config: &Config) -> Token {
/// Get twitter user timeline
fn get_user_timeline(config: &Config, token: Token, lid: Option<u64>) -> Result<Vec<Tweet>, Box<dyn Error>> {
// fix the page size to 200 as it is the maximum Twitter authorizes
let mut rt = Runtime::new()?;
let (_timeline, feed) = rt.block_on(user_timeline(UserID::from(String::from(&config.twitter.username)), true, false, &token)
let (_timeline, feed) = block_on(user_timeline(UserID::from(String::from(&config.twitter.username)), true, false, &token)
.with_page_size(200)
.older(lid))?;