Move library implementation out of core

This commit is contained in:
Wojciech Kozlowski 2024-03-09 18:51:06 +01:00
parent 6d1194226d
commit 93d8ba8cb2
10 changed files with 19 additions and 30 deletions

View File

@ -1,8 +1,5 @@
//! Module for interacting with the music library.
#[cfg(feature = "library-beets")]
pub mod beets;
use std::{collections::HashSet, fmt, num::ParseIntError, str::Utf8Error};
#[cfg(test)]
@ -59,26 +56,16 @@ pub enum Field {
}
/// A library query. Can include or exclude particular fields.
#[derive(Debug, PartialEq, Eq)]
#[derive(Debug, Default, PartialEq, Eq)]
pub struct Query {
include: HashSet<Field>,
exclude: HashSet<Field>,
}
impl Default for Query {
/// Create an empty query.
fn default() -> Self {
Self::new()
}
pub include: HashSet<Field>,
pub exclude: HashSet<Field>,
}
impl Query {
/// Create an empty query.
pub fn new() -> Self {
Query {
include: HashSet::new(),
exclude: HashSet::new(),
}
Query::default()
}
/// Refine the query to include a particular search term.

View File

@ -2,11 +2,13 @@
mod core;
pub mod database;
pub mod library;
pub use core::collection;
pub use core::library;
// TODO: evaluate the exports and/or how to do them
pub use core::database::{IDatabase, NullDatabase};
pub use core::library::{Field, ILibrary, Item, NullLibrary, Query};
pub use core::musichoard::{
musichoard::{MusicHoard, NoDatabase, NoLibrary},

View File

@ -8,7 +8,8 @@ use std::{
str,
};
use crate::core::library::{beets::IBeetsLibraryExecutor, Error};
use crate::core::library::Error;
use crate::library::beets::IBeetsLibraryExecutor;
const BEET_DEFAULT: &str = "beet";

2
src/library/mod.rs Normal file
View File

@ -0,0 +1,2 @@
#[cfg(feature = "library-beets")]
pub mod beets;

View File

@ -11,14 +11,11 @@ use structopt::StructOpt;
use musichoard::{
database::json::{backend::JsonDatabaseFileBackend, JsonDatabase},
library::{
beets::{
executor::{ssh::BeetsLibrarySshExecutor, BeetsLibraryProcessExecutor},
BeetsLibrary,
},
ILibrary, NullLibrary,
library::beets::{
executor::{ssh::BeetsLibrarySshExecutor, BeetsLibraryProcessExecutor},
BeetsLibrary,
},
IDatabase, MusicHoardBuilder, NoDatabase, NoLibrary, NullDatabase,
IDatabase, ILibrary, MusicHoardBuilder, NoDatabase, NoLibrary, NullDatabase, NullLibrary,
};
use tui::{App, EventChannel, EventHandler, EventListener, Tui, Ui};

View File

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

View File

@ -7,8 +7,8 @@ use std::{
use once_cell::sync::Lazy;
use musichoard::library::{
beets::{executor::BeetsLibraryProcessExecutor, BeetsLibrary},
use musichoard::{
library::beets::{executor::BeetsLibraryProcessExecutor, BeetsLibrary},
Field, ILibrary, Item, Query,
};

View File

@ -2,7 +2,7 @@ use once_cell::sync::Lazy;
use musichoard::{
collection::{album::AlbumMonth, track::TrackFormat},
library::Item,
Item,
};
pub static LIBRARY_ITEMS: Lazy<Vec<Item>> = Lazy::new(|| -> Vec<Item> {