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. //! Module for storing MusicHoard data in a database.
#[cfg(feature = "database-json")]
pub mod json;
#[cfg(feature = "database-json")]
mod serde;
use std::fmt; use std::fmt;
#[cfg(test)] #[cfg(test)]

View File

@ -3,7 +3,7 @@
use std::fs; use std::fs;
use std::path::PathBuf; 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. /// JSON database backend that uses a local file for persistent storage.
pub struct JsonDatabaseFileBackend { 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. //! MusicHoard - a music collection manager.
mod core; mod core;
pub mod database;
pub use core::collection; pub use core::collection;
pub use core::database;
pub use core::library; pub use core::library;
pub use core::database::{IDatabase, NullDatabase};
pub use core::musichoard::{ pub use core::musichoard::{
musichoard::{MusicHoard, NoDatabase, NoLibrary}, musichoard::{MusicHoard, NoDatabase, NoLibrary},
musichoard_builder::MusicHoardBuilder, musichoard_builder::MusicHoardBuilder,

View File

@ -10,10 +10,7 @@ use ratatui::{backend::CrosstermBackend, Terminal};
use structopt::StructOpt; use structopt::StructOpt;
use musichoard::{ use musichoard::{
database::{ database::json::{backend::JsonDatabaseFileBackend, JsonDatabase},
json::{backend::JsonDatabaseFileBackend, JsonDatabase},
IDatabase, NullDatabase,
},
library::{ library::{
beets::{ beets::{
executor::{ssh::BeetsLibrarySshExecutor, BeetsLibraryProcessExecutor}, executor::{ssh::BeetsLibrarySshExecutor, BeetsLibraryProcessExecutor},
@ -21,7 +18,7 @@ use musichoard::{
}, },
ILibrary, NullLibrary, ILibrary, NullLibrary,
}, },
MusicHoardBuilder, NoDatabase, NoLibrary, IDatabase, MusicHoardBuilder, NoDatabase, NoLibrary, NullDatabase,
}; };
use tui::{App, EventChannel, EventHandler, EventListener, Tui, Ui}; 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)] #[cfg(test)]
use mockall::automock; use mockall::automock;

View File

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