Move database implementation out of core

This commit is contained in:
Wojciech Kozlowski 2024-03-09 18:34:56 +01:00
parent bd7e9ceb4d
commit 6d1194226d
12 changed files with 13 additions and 17 deletions

View File

@ -1,10 +1,5 @@
//! Module for storing MusicHoard data in a database.
#[cfg(feature = "database-json")]
pub mod json;
#[cfg(feature = "database-json")]
mod serde;
use std::fmt;
#[cfg(test)]

View File

@ -3,7 +3,7 @@
use std::fs;
use std::path::PathBuf;
use crate::core::database::json::IJsonDatabaseBackend;
use crate::database::json::IJsonDatabaseBackend;
/// JSON database backend that uses a local file for persistent storage.
pub struct JsonDatabaseFileBackend {

4
src/database/mod.rs Normal file
View File

@ -0,0 +1,4 @@
#[cfg(feature = "database-json")]
pub mod json;
#[cfg(feature = "database-json")]
mod serde;

View File

@ -1,11 +1,13 @@
//! MusicHoard - a music collection manager.
mod core;
pub mod database;
pub use core::collection;
pub use core::database;
pub use core::library;
pub use core::database::{IDatabase, NullDatabase};
pub use core::musichoard::{
musichoard::{MusicHoard, NoDatabase, NoLibrary},
musichoard_builder::MusicHoardBuilder,

View File

@ -10,10 +10,7 @@ use ratatui::{backend::CrosstermBackend, Terminal};
use structopt::StructOpt;
use musichoard::{
database::{
json::{backend::JsonDatabaseFileBackend, JsonDatabase},
IDatabase, NullDatabase,
},
database::json::{backend::JsonDatabaseFileBackend, JsonDatabase},
library::{
beets::{
executor::{ssh::BeetsLibrarySshExecutor, BeetsLibraryProcessExecutor},
@ -21,7 +18,7 @@ use musichoard::{
},
ILibrary, NullLibrary,
},
MusicHoardBuilder, NoDatabase, NoLibrary,
IDatabase, MusicHoardBuilder, NoDatabase, NoLibrary, NullDatabase,
};
use tui::{App, EventChannel, EventHandler, EventListener, Tui, Ui};

View File

@ -1,4 +1,4 @@
use musichoard::{collection::Collection, database::IDatabase, library::ILibrary, MusicHoard};
use musichoard::{collection::Collection, library::ILibrary, IDatabase, MusicHoard};
#[cfg(test)]
use mockall::automock;

View File

@ -5,10 +5,8 @@ use tempfile::NamedTempFile;
use musichoard::{
collection::{album::AlbumDate, artist::Artist, Collection},
database::{
json::{backend::JsonDatabaseFileBackend, JsonDatabase},
database::json::{backend::JsonDatabaseFileBackend, JsonDatabase},
IDatabase,
},
};
use crate::testlib::COLLECTION;