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 dae9ed791e - Show all commits

View File

@ -4,11 +4,15 @@ use crate::{Album, Track};
use super::{Error, Library, Query, QueryOption};
pub trait SimpleOption {}
trait QueryOptionArgBeets {
fn to_arg(&self, option_name: &str) -> Option<String>;
}
trait SimpleOption {}
impl SimpleOption for String {}
impl SimpleOption for u32 {}
impl<T: SimpleOption + Display> QueryOption<T> {
impl<T: SimpleOption + Display> QueryOptionArgBeets for QueryOption<T> {
fn to_arg(&self, option_name: &str) -> Option<String> {
let (negate, value) = match self {
Self::Include(value) => ("", value),
@ -19,7 +23,7 @@ impl<T: SimpleOption + Display> QueryOption<T> {
}
}
impl QueryOption<Vec<String>> {
impl QueryOptionArgBeets for QueryOption<Vec<String>> {
fn to_arg(&self, option_name: &str) -> Option<String> {
let (negate, vec) = match self {
Self::Include(value) => ("", value),
@ -30,7 +34,11 @@ impl QueryOption<Vec<String>> {
}
}
impl Query {
trait QueryArgsBeets {
fn to_args(&self) -> Vec<String>;
}
impl QueryArgsBeets for Query {
fn to_args(&self) -> Vec<String> {
let mut arguments: Vec<String> = vec![];