diff options
author | Jesse Luehrs <doy@tozt.net> | 2018-11-07 20:05:51 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2018-11-07 20:07:14 -0500 |
commit | f2c66c8e47fddd468b0b6894e7c1902b0baecc16 (patch) | |
tree | 2c80d5c737c6428d9b604d8c2862575c238d5748 /src/db.rs | |
parent | b18c6b8135bfdc884b0a0cf03196d3de0a343490 (diff) | |
download | lastfm-query-f2c66c8e47fddd468b0b6894e7c1902b0baecc16.tar.gz lastfm-query-f2c66c8e47fddd468b0b6894e7c1902b0baecc16.zip |
no need to define my own type here
didn't realize this already existed
Diffstat (limited to 'src/db.rs')
-rw-r--r-- | src/db.rs | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -1,4 +1,3 @@ -use error::Result; use lastfm; use failure::Fail; @@ -17,7 +16,7 @@ pub struct DB { } impl DB { - pub fn new<P: AsRef<std::path::Path>>(path: &P) -> Result<DB> { + pub fn new<P: AsRef<std::path::Path>>(path: &P) -> failure::Fallible<DB> { let conn = if path.as_ref().exists() { rusqlite::Connection::open(path) .map_err(|e| { @@ -37,7 +36,7 @@ impl DB { fn create<P: AsRef<std::path::Path>>( path: &P - ) -> Result<rusqlite::Connection> { + ) -> failure::Fallible<rusqlite::Connection> { println!( "Initializing database at {}", path.as_ref().to_string_lossy(), @@ -62,7 +61,7 @@ impl DB { } } - pub fn most_recent_timestamp(&self) -> Result<Option<i64>> { + pub fn most_recent_timestamp(&self) -> failure::Fallible<Option<i64>> { 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<Item=lastfm::Track>, mut f: F - ) -> Result<()> { + ) -> failure::Fallible<()> { let mut sth = self.conn.prepare("INSERT INTO tracks VALUES (?, ?, ?, ?)")?; for track in tracks { sth.execute( |