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>;
}
trait QueryArgsBeets {
fn to_args(&self) -> Vec<String>;
}
trait SimpleOption {}
impl SimpleOption for String {}
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 {
fn to_args(&self) -> Vec<String> {
let mut arguments: Vec<String> = vec![];
@ -78,12 +78,6 @@ pub struct Beets {
executor: Box<dyn BeetsExecutor>,
}
impl Beets {
pub fn new(executor: Box<dyn BeetsExecutor>) -> Beets {
Beets { executor }
}
}
trait LibraryPrivate {
const CMD_LIST: &'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>;
}
impl Beets {
pub fn new(executor: Box<dyn BeetsExecutor>) -> Beets {
Beets { executor }
}
}
impl Library for Beets {
fn list(&mut self, query: &Query) -> Result<Vec<Album>, Error> {
let cmd = Self::list_cmd_and_args(query);