Hide methods
All checks were successful
Cargo CI / Build and Test (pull_request) Successful in 1m43s
Cargo CI / Lint (pull_request) Successful in 1m15s

This commit is contained in:
Wojciech Kozlowski 2024-03-09 22:46:10 +01:00
parent 80415c085a
commit 3fadd109e7
6 changed files with 18 additions and 12 deletions

View File

@ -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::*;

View File

@ -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()
} }

View File

@ -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,

View File

@ -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)]

View File

@ -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> {

View File

@ -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;