From dae9ed791e9ed52055314b7ac135ee60b1502dc4 Mon Sep 17 00:00:00 2001 From: Wojciech Kozlowski Date: Thu, 30 Mar 2023 23:42:48 +0900 Subject: [PATCH] Use traits to keep things private --- src/library/beets.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/library/beets.rs b/src/library/beets.rs index 13679d5..26aab1c 100644 --- a/src/library/beets.rs +++ b/src/library/beets.rs @@ -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; +} + +trait SimpleOption {} impl SimpleOption for String {} impl SimpleOption for u32 {} -impl QueryOption { +impl QueryOptionArgBeets for QueryOption { fn to_arg(&self, option_name: &str) -> Option { let (negate, value) = match self { Self::Include(value) => ("", value), @@ -19,7 +23,7 @@ impl QueryOption { } } -impl QueryOption> { +impl QueryOptionArgBeets for QueryOption> { fn to_arg(&self, option_name: &str) -> Option { let (negate, vec) = match self { Self::Include(value) => ("", value), @@ -30,7 +34,11 @@ impl QueryOption> { } } -impl Query { +trait QueryArgsBeets { + fn to_args(&self) -> Vec; +} + +impl QueryArgsBeets for Query { fn to_args(&self) -> Vec { let mut arguments: Vec = vec![];