diff --git a/src/core/database/mod.rs b/src/core/database/mod.rs index 7e8cbcd..b3882c1 100644 --- a/src/core/database/mod.rs +++ b/src/core/database/mod.rs @@ -10,7 +10,7 @@ use std::fmt; #[cfg(test)] use mockall::automock; -use crate::core::collection::Collection; +use crate::core::collection::{self, Collection}; /// Trait for interacting with the database. #[cfg_attr(test, automock)] @@ -61,6 +61,14 @@ impl From for LoadError { } } +impl From for LoadError { + fn from(err: collection::Error) -> Self { + match err { + collection::Error::UrlError(e) => LoadError::SerDeError(e), + } + } +} + /// Error type for database calls. #[derive(Debug)] pub enum SaveError { @@ -111,6 +119,10 @@ mod tests { assert!(!io_err.to_string().is_empty()); assert!(!format!("{:?}", io_err).is_empty()); + let col_err: LoadError = collection::Error::UrlError(String::from("get rekt")).into(); + assert!(!col_err.to_string().is_empty()); + assert!(!format!("{:?}", col_err).is_empty()); + let io_err: SaveError = io::Error::new(io::ErrorKind::Interrupted, "error").into(); assert!(!io_err.to_string().is_empty()); assert!(!format!("{:?}", io_err).is_empty()); diff --git a/src/core/database/serde/deserialize.rs b/src/core/database/serde/deserialize.rs index 35c63b3..a4f0e16 100644 --- a/src/core/database/serde/deserialize.rs +++ b/src/core/database/serde/deserialize.rs @@ -3,10 +3,7 @@ use std::collections::HashMap; use serde::Deserialize; use crate::{ - collection::{ - self, - artist::{ArtistId, MusicBrainz}, - }, + collection::artist::{ArtistId, MusicBrainz}, core::{ collection::{artist::Artist, Collection}, database::{serde::Database, LoadError}, @@ -49,25 +46,3 @@ impl TryFrom for Artist { }) } } - -impl From for LoadError { - fn from(err: collection::Error) -> Self { - match err { - collection::Error::UrlError(e) => LoadError::SerDeError(e), - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn errors() { - let col_err: LoadError = collection::Error::UrlError(String::from("get rekt")).into(); - - assert!(!col_err.to_string().is_empty()); - - assert!(!format!("{:?}", col_err).is_empty()); - } -}