From 980932778455716f6e789cb31d773e6f0b45a43e Mon Sep 17 00:00:00 2001 From: VC Date: Tue, 19 May 2020 22:33:19 +0200 Subject: [PATCH] Use futures instead of tokio (for just one call, sounds more appropriate) --- Cargo.lock | 4 ++-- Cargo.toml | 4 ++-- src/lib.rs | 7 +++---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0a528e0..469c4ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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", ] diff --git a/Cargo.toml b/Cargo.toml index e937f5e..5994631 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "scootaloo" -version = "0.2.0" +version = "0.2.1" authors = ["VC "] 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" diff --git a/src/lib.rs b/src/lib.rs index 07ab08b..c262876 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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) -> Result, Box> { // 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))?;