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.
|
//! Module for interacting with the music library.
|
||||||
|
|
||||||
#[cfg(feature = "library-beets")]
|
|
||||||
pub mod beets;
|
|
||||||
|
|
||||||
use std::{collections::HashSet, fmt, num::ParseIntError, str::Utf8Error};
|
use std::{collections::HashSet, fmt, num::ParseIntError, str::Utf8Error};
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@ -59,26 +56,16 @@ pub enum Field {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A library query. Can include or exclude particular fields.
|
/// A library query. Can include or exclude particular fields.
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, Default, PartialEq, Eq)]
|
||||||
pub struct Query {
|
pub struct Query {
|
||||||
include: HashSet<Field>,
|
pub include: HashSet<Field>,
|
||||||
exclude: HashSet<Field>,
|
pub exclude: HashSet<Field>,
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for Query {
|
|
||||||
/// Create an empty query.
|
|
||||||
fn default() -> Self {
|
|
||||||
Self::new()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Query {
|
impl Query {
|
||||||
/// Create an empty query.
|
/// Create an empty query.
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Query {
|
Query::default()
|
||||||
include: HashSet::new(),
|
|
||||||
exclude: HashSet::new(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Refine the query to include a particular search term.
|
/// Refine the query to include a particular search term.
|
||||||
|
@ -2,11 +2,13 @@
|
|||||||
|
|
||||||
mod core;
|
mod core;
|
||||||
pub mod database;
|
pub mod database;
|
||||||
|
pub mod library;
|
||||||
|
|
||||||
pub use core::collection;
|
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::database::{IDatabase, NullDatabase};
|
||||||
|
pub use core::library::{Field, ILibrary, Item, NullLibrary, Query};
|
||||||
|
|
||||||
pub use core::musichoard::{
|
pub use core::musichoard::{
|
||||||
musichoard::{MusicHoard, NoDatabase, NoLibrary},
|
musichoard::{MusicHoard, NoDatabase, NoLibrary},
|
||||||
|
@ -8,7 +8,8 @@ use std::{
|
|||||||
str,
|
str,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::core::library::{beets::IBeetsLibraryExecutor, Error};
|
use crate::core::library::Error;
|
||||||
|
use crate::library::beets::IBeetsLibraryExecutor;
|
||||||
|
|
||||||
const BEET_DEFAULT: &str = "beet";
|
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
src/main.rs
11
src/main.rs
@ -11,14 +11,11 @@ use structopt::StructOpt;
|
|||||||
|
|
||||||
use musichoard::{
|
use musichoard::{
|
||||||
database::json::{backend::JsonDatabaseFileBackend, JsonDatabase},
|
database::json::{backend::JsonDatabaseFileBackend, JsonDatabase},
|
||||||
library::{
|
library::beets::{
|
||||||
beets::{
|
executor::{ssh::BeetsLibrarySshExecutor, BeetsLibraryProcessExecutor},
|
||||||
executor::{ssh::BeetsLibrarySshExecutor, BeetsLibraryProcessExecutor},
|
BeetsLibrary,
|
||||||
BeetsLibrary,
|
|
||||||
},
|
|
||||||
ILibrary, NullLibrary,
|
|
||||||
},
|
},
|
||||||
IDatabase, MusicHoardBuilder, NoDatabase, NoLibrary, NullDatabase,
|
IDatabase, ILibrary, MusicHoardBuilder, NoDatabase, NoLibrary, NullDatabase, NullLibrary,
|
||||||
};
|
};
|
||||||
|
|
||||||
use tui::{App, EventChannel, EventHandler, EventListener, Tui, Ui};
|
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)]
|
#[cfg(test)]
|
||||||
use mockall::automock;
|
use mockall::automock;
|
||||||
|
@ -7,8 +7,8 @@ use std::{
|
|||||||
|
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
use musichoard::library::{
|
use musichoard::{
|
||||||
beets::{executor::BeetsLibraryProcessExecutor, BeetsLibrary},
|
library::beets::{executor::BeetsLibraryProcessExecutor, BeetsLibrary},
|
||||||
Field, ILibrary, Item, Query,
|
Field, ILibrary, Item, Query,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ use once_cell::sync::Lazy;
|
|||||||
|
|
||||||
use musichoard::{
|
use musichoard::{
|
||||||
collection::{album::AlbumMonth, track::TrackFormat},
|
collection::{album::AlbumMonth, track::TrackFormat},
|
||||||
library::Item,
|
Item,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub static LIBRARY_ITEMS: Lazy<Vec<Item>> = Lazy::new(|| -> Vec<Item> {
|
pub static LIBRARY_ITEMS: Lazy<Vec<Item>> = Lazy::new(|| -> Vec<Item> {
|
||||||
|
Loading…
Reference in New Issue
Block a user