Break down the musichoard files #165
@ -146,7 +146,10 @@ impl<Database: IDatabase, Library: ILibrary> MusicHoard<Database, Library> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::core::interface::{database::NullDatabase, library::NullLibrary};
|
||||
use crate::core::{
|
||||
interface::{database::NullDatabase, library::NullLibrary},
|
||||
musichoard::library::IMusicHoardLibrary,
|
||||
};
|
||||
|
||||
use super::*;
|
||||
|
||||
|
@ -17,17 +17,19 @@ use crate::core::{
|
||||
},
|
||||
};
|
||||
|
||||
impl<Library: ILibrary> MusicHoard<NoDatabase, Library> {
|
||||
/// Rescan the library and merge with the in-memory collection.
|
||||
pub fn rescan_library(&mut self) -> Result<(), Error> {
|
||||
pub trait IMusicHoardLibrary {
|
||||
fn rescan_library(&mut self) -> Result<(), Error>;
|
||||
}
|
||||
|
||||
impl<Library: ILibrary> IMusicHoardLibrary for MusicHoard<NoDatabase, Library> {
|
||||
fn rescan_library(&mut self) -> Result<(), Error> {
|
||||
self.pre_commit = self.rescan_library_inner()?;
|
||||
self.commit()
|
||||
}
|
||||
}
|
||||
|
||||
impl<Database: IDatabase, Library: ILibrary> MusicHoard<Database, Library> {
|
||||
/// Rescan the library and merge with the in-memory collection.
|
||||
pub fn rescan_library(&mut self) -> Result<(), Error> {
|
||||
impl<Database: IDatabase, Library: ILibrary> IMusicHoardLibrary for MusicHoard<Database, Library> {
|
||||
fn rescan_library(&mut self) -> Result<(), Error> {
|
||||
self.pre_commit = self.rescan_library_inner()?;
|
||||
self.commit()
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ pub mod builder;
|
||||
|
||||
pub use base::IMusicHoardBase;
|
||||
pub use database::IMusicHoardDatabase;
|
||||
pub use library::IMusicHoardLibrary;
|
||||
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
|
@ -8,8 +8,8 @@ pub use core::collection;
|
||||
pub use core::interface;
|
||||
|
||||
pub use core::musichoard::{
|
||||
builder::MusicHoardBuilder, Error, IMusicHoardBase, IMusicHoardDatabase, MusicHoard,
|
||||
NoDatabase, NoLibrary,
|
||||
builder::MusicHoardBuilder, Error, IMusicHoardBase, IMusicHoardDatabase, IMusicHoardLibrary,
|
||||
MusicHoard, NoDatabase, NoLibrary,
|
||||
};
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -1,6 +1,6 @@
|
||||
use musichoard::{
|
||||
collection::Collection, interface::database::IDatabase, interface::library::ILibrary,
|
||||
IMusicHoardBase, IMusicHoardDatabase, MusicHoard,
|
||||
IMusicHoardBase, IMusicHoardDatabase, IMusicHoardLibrary, MusicHoard,
|
||||
};
|
||||
|
||||
#[cfg(test)]
|
||||
@ -16,7 +16,7 @@ pub trait IMusicHoard {
|
||||
// GRCOV_EXCL_START
|
||||
impl<Database: IDatabase, Library: ILibrary> IMusicHoard for MusicHoard<Database, Library> {
|
||||
fn rescan_library(&mut self) -> Result<(), musichoard::Error> {
|
||||
Self::rescan_library(self)
|
||||
<Self as IMusicHoardLibrary>::rescan_library(self)
|
||||
}
|
||||
|
||||
fn reload_database(&mut self) -> Result<(), musichoard::Error> {
|
||||
|
@ -9,7 +9,7 @@ mod testlib;
|
||||
use musichoard::{
|
||||
database::json::{backend::JsonDatabaseFileBackend, JsonDatabase},
|
||||
library::beets::{executor::BeetsLibraryProcessExecutor, BeetsLibrary},
|
||||
IMusicHoardBase, IMusicHoardDatabase, MusicHoard,
|
||||
IMusicHoardBase, IMusicHoardDatabase, IMusicHoardLibrary, MusicHoard,
|
||||
};
|
||||
|
||||
use crate::testlib::COLLECTION;
|
||||
|
Loading…
Reference in New Issue
Block a user