Move library implementation out of core
This commit is contained in:
parent
6d1194226d
commit
93d8ba8cb2
@ -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.
|
||||
|
@ -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},
|
||||
|
@ -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
2
src/library/mod.rs
Normal file
@ -0,0 +1,2 @@
|
||||
#[cfg(feature = "library-beets")]
|
||||
pub mod beets;
|
@ -11,14 +11,11 @@ use structopt::StructOpt;
|
||||
|
||||
use musichoard::{
|
||||
database::json::{backend::JsonDatabaseFileBackend, JsonDatabase},
|
||||
library::{
|
||||
beets::{
|
||||
library::beets::{
|
||||
executor::{ssh::BeetsLibrarySshExecutor, BeetsLibraryProcessExecutor},
|
||||
BeetsLibrary,
|
||||
},
|
||||
ILibrary, NullLibrary,
|
||||
},
|
||||
IDatabase, MusicHoardBuilder, NoDatabase, NoLibrary, NullDatabase,
|
||||
IDatabase, ILibrary, MusicHoardBuilder, NoDatabase, NoLibrary, NullDatabase, NullLibrary,
|
||||
};
|
||||
|
||||
use tui::{App, EventChannel, EventHandler, EventListener, Tui, Ui};
|
||||
|
@ -1,4 +1,4 @@
|
||||
use musichoard::{collection::Collection, library::ILibrary, IDatabase, MusicHoard};
|
||||
use musichoard::{collection::Collection, IDatabase, ILibrary, MusicHoard};
|
||||
|
||||
#[cfg(test)]
|
||||
use mockall::automock;
|
||||
|
@ -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,
|
||||
};
|
||||
|
||||
|
@ -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> {
|
||||
|
Loading…
Reference in New Issue
Block a user