diff --git a/src/library/beets.rs b/src/library/beets.rs index 072a9c7..d10f76a 100644 --- a/src/library/beets.rs +++ b/src/library/beets.rs @@ -95,7 +95,7 @@ trait LibraryPrivate { } impl BeetsLibrary { - /// Create a new beets library with the provided executor, e.g. [`BeetsLibraryCommandExecutor`]. + /// Create a new beets library with the provided executor, e.g. [`BeetsLibraryProcessExecutor`]. pub fn new(executor: BLE) -> Self { BeetsLibrary { executor } } @@ -199,15 +199,15 @@ impl LibraryPrivate for BeetsLibrary { } /// Beets library executor that executes beets commands in their own process. -pub struct BeetsLibraryCommandExecutor { +pub struct BeetsLibraryProcessExecutor { bin: OsString, config: Option, } -impl BeetsLibraryCommandExecutor { - /// Create a new [`BeetsLibraryCommandExecutor`] that uses the provided beets executable. +impl BeetsLibraryProcessExecutor { + /// Create a new [`BeetsLibraryProcessExecutor`] that uses the provided beets executable. pub fn new>(bin: S) -> Self { - BeetsLibraryCommandExecutor { + BeetsLibraryProcessExecutor { bin: bin.into(), config: None, } @@ -220,14 +220,14 @@ impl BeetsLibraryCommandExecutor { } } -impl Default for BeetsLibraryCommandExecutor { - /// Create a new [`BeetsLibraryCommandExecutor`] that uses the system's default beets executable. +impl Default for BeetsLibraryProcessExecutor { + /// Create a new [`BeetsLibraryProcessExecutor`] that uses the system's default beets executable. fn default() -> Self { - BeetsLibraryCommandExecutor::new("beet") + BeetsLibraryProcessExecutor::new("beet") } } -impl BeetsLibraryExecutor for BeetsLibraryCommandExecutor { +impl BeetsLibraryExecutor for BeetsLibraryProcessExecutor { fn exec + 'static>(&mut self, arguments: &[S]) -> Result, Error> { let mut cmd = Command::new(&self.bin); if let Some(ref path) = self.config { diff --git a/src/main.rs b/src/main.rs index cc241d5..957f9c8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,7 +8,7 @@ use structopt::StructOpt; use musichoard::{ collection::MhCollectionManager, database::json::{JsonDatabase, JsonDatabaseFileBackend}, - library::beets::{BeetsLibrary, BeetsLibraryCommandExecutor}, + library::beets::{BeetsLibrary, BeetsLibraryProcessExecutor}, }; mod tui; @@ -42,7 +42,7 @@ fn main() { let opt = Opt::from_args(); let beets = BeetsLibrary::new( - BeetsLibraryCommandExecutor::default().config(opt.beets_config_file_path.as_deref()), + BeetsLibraryProcessExecutor::default().config(opt.beets_config_file_path.as_deref()), ); let database = JsonDatabase::new(JsonDatabaseFileBackend::new(&opt.database_file_path)); diff --git a/tests/library/beets.rs b/tests/library/beets.rs index ac4d358..8b97f45 100644 --- a/tests/library/beets.rs +++ b/tests/library/beets.rs @@ -8,7 +8,7 @@ use once_cell::sync::Lazy; use musichoard::{ library::{ - beets::{BeetsLibrary, BeetsLibraryCommandExecutor}, + beets::{BeetsLibrary, BeetsLibraryProcessExecutor}, Field, Library, Query, }, Artist, @@ -16,17 +16,17 @@ use musichoard::{ use crate::COLLECTION; -static BEETS_EMPTY_CONFIG: Lazy>>> = +static BEETS_EMPTY_CONFIG: Lazy>>> = Lazy::new(|| { Arc::new(Mutex::new(BeetsLibrary::new( - BeetsLibraryCommandExecutor::default(), + BeetsLibraryProcessExecutor::default(), ))) }); -static BEETS_TEST_CONFIG: Lazy>>> = +static BEETS_TEST_CONFIG: Lazy>>> = Lazy::new(|| { Arc::new(Mutex::new(BeetsLibrary::new( - BeetsLibraryCommandExecutor::default().config(Some( + BeetsLibraryProcessExecutor::default().config(Some( &fs::canonicalize("./tests/files/library/config.yml").unwrap(), )), ))) @@ -45,7 +45,7 @@ fn test_no_config_list() { #[test] fn test_invalid_config() { - let mut beets = BeetsLibrary::new(BeetsLibraryCommandExecutor::default().config(Some( + let mut beets = BeetsLibrary::new(BeetsLibraryProcessExecutor::default().config(Some( &PathBuf::from("./tests/files/library/config-does-not-exist.yml"), )));