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/db.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/db.rs') diff --git a/src/db.rs b/src/db.rs index 0d81d7e..67dec84 100644 --- a/src/db.rs +++ b/src/db.rs @@ -1,4 +1,3 @@ -use error::Result; use lastfm; use failure::Fail; @@ -17,7 +16,7 @@ pub struct DB { } impl DB { - pub fn new>(path: &P) -> Result { + pub fn new>(path: &P) -> failure::Fallible { let conn = if path.as_ref().exists() { rusqlite::Connection::open(path) .map_err(|e| { @@ -37,7 +36,7 @@ impl DB { fn create>( path: &P - ) -> Result { + ) -> failure::Fallible { println!( "Initializing database at {}", path.as_ref().to_string_lossy(), @@ -62,7 +61,7 @@ impl DB { } } - pub fn most_recent_timestamp(&self) -> Result> { + pub fn most_recent_timestamp(&self) -> failure::Fallible> { Ok(self.conn.query_row( "SELECT timestamp FROM tracks ORDER BY timestamp DESC LIMIT 1", rusqlite::NO_PARAMS, @@ -79,7 +78,7 @@ impl DB { &self, tracks: impl Iterator, mut f: F - ) -> Result<()> { + ) -> failure::Fallible<()> { let mut sth = self.conn.prepare("INSERT INTO tracks VALUES (?, ?, ?, ?)")?; for track in tracks { sth.execute( -- cgit v1.2.3-54-g00ecf