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