From f2c66c8e47fddd468b0b6894e7c1902b0baecc16 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Wed, 7 Nov 2018 20:05:51 -0500 Subject: no need to define my own type here didn't realize this already existed --- src/lastfm/mod.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/lastfm/mod.rs') diff --git a/src/lastfm/mod.rs b/src/lastfm/mod.rs index b510eb3..53e501e 100644 --- a/src/lastfm/mod.rs +++ b/src/lastfm/mod.rs @@ -1,8 +1,6 @@ use failure; use reqwest; -use error::Result; - mod api_types; const API_ROOT: &'static str = "https://ws.audioscrobbler.com/2.0/"; @@ -37,7 +35,7 @@ impl<'a> Tracks<'a> { } } - fn get_next_page(&mut self) -> Result<()> { + fn get_next_page(&mut self) -> failure::Fallible<()> { if !self.page.is_some() { self.page = Some(self.client.get_total_pages(self.from)?); } @@ -78,7 +76,7 @@ impl<'a> Tracks<'a> { timestamp: t.date.as_ref().unwrap().uts.parse()?, }) }) - .collect::>>()?; + .collect::>>()?; self.page = Some(page - 1); Ok(()) } @@ -111,7 +109,7 @@ impl LastFMClient { } } - pub fn track_count(&self, from: Option) -> Result { + pub fn track_count(&self, from: Option) -> failure::Fallible { let data = self.recent_tracks(from)?; Ok(data.recenttracks.attr.total.parse()?) } @@ -120,7 +118,7 @@ impl LastFMClient { Tracks::new(&self, from) } - fn get_total_pages(&self, from: Option) -> Result { + fn get_total_pages(&self, from: Option) -> failure::Fallible { let data = self.recent_tracks(from)?; Ok(data.recenttracks.attr.totalPages.parse()?) } @@ -128,7 +126,7 @@ impl LastFMClient { fn recent_tracks( &self, from: Option, - ) -> Result { + ) -> failure::Fallible { let req = self.client .get(API_ROOT) .query(&[ -- cgit v1.2.3-54-g00ecf