@@ -35,65 +35,38 @@ impl<'a> Filter<'a> {
35
35
}
36
36
}
37
37
38
- pub struct Query < ' a , S : ' a + Read + Write > {
39
- client : & ' a mut Client < S > ,
38
+ pub struct Query < ' a > {
40
39
filters : Vec < Filter < ' a > > ,
41
40
groups : Option < Vec < Cow < ' a , str > > > ,
42
41
window : Option < ( u32 , u32 ) > ,
43
42
}
44
43
45
- impl < ' a , S : ' a + Read + Write > Query < ' a , S > {
46
- pub fn new ( client : & ' a mut Client < S > ) -> Query < ' a , S > {
44
+ impl < ' a > Query < ' a > {
45
+ pub fn new ( ) -> Query < ' a > {
47
46
Query {
48
- client : client,
49
47
filters : Vec :: new ( ) ,
50
48
groups : None ,
51
49
window : None ,
52
50
}
53
51
}
54
52
55
- pub fn and < ' b : ' a , V : ' b + Into < Cow < ' b , str > > > ( & ' a mut self , term : Term < ' b > , value : V ) -> & ' a mut Query < ' a , S > {
53
+ pub fn and < ' b : ' a , V : ' b + Into < Cow < ' b , str > > > ( & ' a mut self , term : Term < ' b > , value : V ) -> & ' a mut Query < ' a > {
56
54
self . filters . push ( Filter :: new ( term, value) ) ;
57
55
self
58
56
}
59
57
60
- pub fn limit ( & ' a mut self , offset : u32 , limit : u32 ) -> & ' a mut Query < ' a , S > {
58
+ pub fn limit ( & ' a mut self , offset : u32 , limit : u32 ) -> & ' a mut Query < ' a > {
61
59
self . window = Some ( ( offset, limit) ) ;
62
60
self
63
61
}
64
62
65
- pub fn group < ' b : ' a , G : ' b + Into < Cow < ' b , str > > > ( & ' a mut self , group : G ) -> & ' a mut Query < ' a , S > {
63
+ pub fn group < ' b : ' a , G : ' b + Into < Cow < ' b , str > > > ( & ' a mut self , group : G ) -> & ' a mut Query < ' a > {
66
64
match self . groups {
67
65
None => self . groups = Some ( vec ! [ group. into( ) ] ) ,
68
66
Some ( ref mut groups) => groups. push ( group. into ( ) ) ,
69
67
} ;
70
68
self
71
69
}
72
-
73
- pub fn find ( mut self , fuzzy : bool , add : bool ) -> Result < Vec < Song > > {
74
- let cmd = if fuzzy { if add { "searchadd" } else { "search" } } else { if add { "findadd" } else { "find" } } ;
75
- let args = self . to_string ( ) ;
76
-
77
- self . client
78
- . run_command_fmt ( format_args ! ( "{} {}" , cmd, args) )
79
- . and_then ( |_| {
80
- self . client
81
- . read_pairs ( )
82
- . split ( "file" )
83
- . map ( |v| v. and_then ( FromMap :: from_map) )
84
- . collect ( )
85
- } )
86
- }
87
-
88
- pub fn find_add < N : ToPlaylistName > ( mut self , playlist : N ) -> Result < ( ) > {
89
- let args = self . to_string ( ) ;
90
- self . client
91
- . run_command_fmt ( format_args ! ( "searchaddpl {} {}" , playlist. to_name( ) , args) )
92
- . and_then ( |_| self . client . expect_ok ( ) )
93
- }
94
-
95
- // pub fn list(mut self, ty: &str) -> Result<Vec<???>> {
96
- // }
97
70
}
98
71
99
72
impl < ' a > fmt:: Display for Term < ' a > {
@@ -110,19 +83,19 @@ impl<'a> fmt::Display for Term<'a> {
110
83
111
84
impl < ' a > fmt:: Display for Filter < ' a > {
112
85
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
113
- write ! ( f, "{} {} " , self . typ, self . what)
86
+ write ! ( f, " {} \" {} \" " , self . typ, self . what)
114
87
}
115
88
}
116
89
117
- impl < ' a , S : ' a + Read + Write > fmt:: Display for Query < ' a , S > {
90
+ impl < ' a > fmt:: Display for Query < ' a > {
118
91
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
119
92
for filter in & self . filters {
120
93
try!( filter. fmt ( f) ) ;
121
94
}
122
95
123
96
if let Some ( ref groups) = self . groups {
124
97
for group in groups {
125
- try!( write ! ( f, "group {}" , group) ) ;
98
+ try!( write ! ( f, " group {}" , group) ) ;
126
99
}
127
100
}
128
101
0 commit comments