From 08ebb9e7d610c7dcec61f9987cf2899003cda8d0 Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Sat, 14 Apr 2018 08:03:58 +0300 Subject: [PATCH] pipeline: Make `run` function generic again. also minor formatting changes. --- hammond-data/src/pipeline.rs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/hammond-data/src/pipeline.rs b/hammond-data/src/pipeline.rs index f72abda..f71d3ce 100644 --- a/hammond-data/src/pipeline.rs +++ b/hammond-data/src/pipeline.rs @@ -38,18 +38,23 @@ macro_rules! clone { ); } +type HttpsClient = Client>; + /// The pipline to be run for indexing and updating a Podcast feed that originates from /// `Source.uri`. /// /// Messy temp diagram: -/// Source -> GET Request -> Update Etags -> Check Status -> Parse xml/Rss -> -/// Convert `rss::Channel` into Feed -> Index Podcast -> Index Episodes. -pub fn pipeline>( +/// Source -> GET Request -> Update Etags -> Check Status -> Parse `xml/Rss` -> +/// Convert `rss::Channel` into `Feed` -> Index Podcast -> Index Episodes. +pub fn pipeline( sources: S, ignore_etags: bool, tokio_core: &mut Core, - client: Client>, -) -> Result<(), DataError> { + client: HttpsClient, +) -> Result<(), DataError> +where + S: IntoIterator, +{ let list: Vec<_> = sources .into_iter() .map(clone!(client => move |s| s.into_feed(client.clone(), ignore_etags))) @@ -67,11 +72,10 @@ pub fn pipeline>( /// Creates a tokio `reactor::Core`, and a `hyper::Client` and /// runs the pipeline. -pub fn run(sources: Vec, ignore_etags: bool) -> Result<(), DataError> { - if sources.is_empty() { - return Ok(()); - } - +pub fn run(sources: S, ignore_etags: bool) -> Result<(), DataError> +where + S: IntoIterator, +{ let mut core = Core::new()?; let handle = core.handle(); let client = Client::configure()