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 565d29e548 - Show all commits

View File

@ -86,7 +86,7 @@ impl Beets {
trait LibraryPrivate { trait LibraryPrivate {
const CMD_LIST: &'static str; const CMD_LIST: &'static str;
const SEPARATOR: &'static str; const LIST_FORMAT_SEPARATOR: &'static str;
const LIST_FORMAT: &'static str; const LIST_FORMAT: &'static str;
fn list_cmd_and_args(query: &Query) -> Vec<String>; fn list_cmd_and_args(query: &Query) -> Vec<String>;
@ -101,7 +101,7 @@ impl Library for Beets {
} }
} }
macro_rules! separator { macro_rules! list_format_separator {
() => { () => {
"-*^-" "-*^-"
}; };
@ -109,19 +109,19 @@ macro_rules! separator {
impl LibraryPrivate for Beets { impl LibraryPrivate for Beets {
const CMD_LIST: &'static str = "ls"; const CMD_LIST: &'static str = "ls";
const SEPARATOR: &'static str = separator!(); const LIST_FORMAT_SEPARATOR: &'static str = list_format_separator!();
const LIST_FORMAT: &'static str = concat!( const LIST_FORMAT: &'static str = concat!(
"--format=", "--format=",
"$albumartist", "$albumartist",
separator!(), list_format_separator!(),
"$year", "$year",
separator!(), list_format_separator!(),
"$album", "$album",
separator!(), list_format_separator!(),
"$track", "$track",
separator!(), list_format_separator!(),
"$title", "$title",
separator!(), list_format_separator!(),
"$artist" "$artist"
); );
@ -137,7 +137,7 @@ impl LibraryPrivate for Beets {
let mut album_ids = HashSet::<AlbumId>::new(); let mut album_ids = HashSet::<AlbumId>::new();
for line in list_output.iter() { for line in list_output.iter() {
let split: Vec<&str> = line.split(Self::SEPARATOR).collect(); let split: Vec<&str> = line.split(Self::LIST_FORMAT_SEPARATOR).collect();
if split.len() != 6 { if split.len() != 6 {
return Err(Error::InvalidData(line.to_string())); return Err(Error::InvalidData(line.to_string()));
@ -285,7 +285,7 @@ mod tests {
strings.push(format!( strings.push(format!(
"{album_artist}{0}{album_year}{0}{album_title}{0}\ "{album_artist}{0}{album_year}{0}{album_title}{0}\
{track_number}{0}{track_title}{0}{track_artist}", {track_number}{0}{track_title}{0}{track_artist}",
Beets::SEPARATOR, Beets::LIST_FORMAT_SEPARATOR,
)); ));
} }