Resolve "Local collection trait and beets implementation" #9

Merged
wojtek merged 12 commits from 4---local-collection-trait-and-beets-implementation into main 2023-03-31 14:24:54 +02:00
Showing only changes of commit b1058f5a0b - Show all commits

View File

@ -8,6 +8,10 @@ trait QueryOptionArgBeets {
fn to_arg(&self, option_name: &str) -> Option<String>; fn to_arg(&self, option_name: &str) -> Option<String>;
} }
trait QueryArgsBeets {
fn to_args(&self) -> Vec<String>;
}
trait SimpleOption {} trait SimpleOption {}
impl SimpleOption for String {} impl SimpleOption for String {}
impl SimpleOption for u32 {} impl SimpleOption for u32 {}
@ -34,10 +38,6 @@ impl QueryOptionArgBeets for QueryOption<Vec<String>> {
} }
} }
trait QueryArgsBeets {
fn to_args(&self) -> Vec<String>;
}
impl QueryArgsBeets for Query { impl QueryArgsBeets for Query {
fn to_args(&self) -> Vec<String> { fn to_args(&self) -> Vec<String> {
let mut arguments: Vec<String> = vec![]; let mut arguments: Vec<String> = vec![];
@ -78,12 +78,6 @@ pub struct Beets {
executor: Box<dyn BeetsExecutor>, executor: Box<dyn BeetsExecutor>,
} }
impl Beets {
pub fn new(executor: Box<dyn BeetsExecutor>) -> Beets {
Beets { executor }
}
}
trait LibraryPrivate { trait LibraryPrivate {
const CMD_LIST: &'static str; const CMD_LIST: &'static str;
const LIST_FORMAT_SEPARATOR: &'static str; const LIST_FORMAT_SEPARATOR: &'static str;
@ -93,6 +87,12 @@ trait LibraryPrivate {
fn list_to_albums(list_output: Vec<String>) -> Result<Vec<Album>, Error>; fn list_to_albums(list_output: Vec<String>) -> Result<Vec<Album>, Error>;
} }
impl Beets {
pub fn new(executor: Box<dyn BeetsExecutor>) -> Beets {
Beets { executor }
}
}
impl Library for Beets { impl Library for Beets {
fn list(&mut self, query: &Query) -> Result<Vec<Album>, Error> { fn list(&mut self, query: &Query) -> Result<Vec<Album>, Error> {
let cmd = Self::list_cmd_and_args(query); let cmd = Self::list_cmd_and_args(query);