1
use crate::{common::SubSystem, Request, Response};
2

            
3
pub trait MPDServer {
4
    type Error;
5

            
6
    fn route_request(&mut self, request: Request) -> Result<Response, Self::Error> {
7
        match request {
8
            Request::ClearError => self.handle_clear_error().map(|_| Ok(())),
9
            Request::CurrentSong => self.handle_current_song().map(|_| Ok(())),
10
            Request::Idle(subsystems) => self.handle_idle(subsystems).map(|_| Ok(())),
11
            Request::Status => self.handle_status().map(|_| Ok(())),
12
            Request::Stats => self.handle_stats().map(|_| Ok(())),
13
            _ => unimplemented!(),
14
        }
15
    }
16

            
17
    fn handle_unimplemented(&mut self) -> Result<(), Self::Error> {
18
        // fn handle_unimplemented(&mut self, name: &str) -> Result<(), Self::Error> {
19
        // return Err("a".into());
20
        unimplemented!()
21
    }
22

            
23
    // -- Query Commands -- //
24
    fn handle_clear_error(&mut self) -> Result<(), Self::Error> {
25
        self.handle_unimplemented()
26
    }
27
    fn handle_current_song(&mut self) -> Result<(), Self::Error> {
28
        self.handle_unimplemented()
29
    }
30
    fn handle_idle(&mut self, _: Option<Vec<SubSystem>>) -> Result<(), Self::Error> {
31
        self.handle_unimplemented()
32
    }
33
    fn handle_status(&mut self) -> Result<(), Self::Error> {
34
        self.handle_unimplemented()
35
    }
36
    fn handle_stats(&mut self) -> Result<(), Self::Error> {
37
        self.handle_unimplemented()
38
    }
39

            
40
    // -- Playback Commands -- //
41
    // handle_consume(ConsumeState),
42
    // handle_crossfade(Seconds),
43
    // handle_mix_ramp_db(f32),
44
    // handle_mix_ramp_delay(Seconds),
45
    // handle_random(bool),
46
    // handle_repeat(bool),
47
    // handle_set_vol(Volume),
48
    // handle_get_vol,
49
    // handle_single(SingleState),
50
    // handle_replay_gain_mode(ReplayGainMode),
51
    // handle_replay_gain_status,
52
    // handle_volume(Volume),
53

            
54
    // // -- Playback Control Commands -- //
55
    // next,
56
    // pause(Option<bool>),
57
    // play(SongPosition),
58
    // play_id(SongId),
59
    // previous,
60
    // seek(SongPosition, TimeWithFractions),
61
    // seek_id(SongId, TimeWithFractions),
62
    // seek_cur(SeekMode, TimeWithFractions),
63
    // stop,
64

            
65
    // // -- Queue Commands -- //
66
    // handle_add(String, Option<SongPosition>),
67
    // handle_add_id(String, Option<SongPosition>),
68
    // handle_clear,
69
    // handle_delete(OneOrRange),
70
    // handle_delete_id(SongId),
71
    // handle_move(OneOrRange, SongPosition),
72
    // handle_move_id(SongId, SongPosition),
73
    // handle_playlist,
74
    // handle_playlist_find(Filter, Option<Sort>, Option<WindowRange>),
75
    // handle_playlist_id(SongId),
76
    // handle_playlist_info(OneOrRange),
77
    // handle_playlist_search(Filter, Option<Sort>, Option<WindowRange>),
78
    // handle_pl_changes(Version, Option<WindowRange>),
79
    // handle_pl_changes_pos_id(Version, Option<WindowRange>),
80
    // handle_prio(Priority, WindowRange),
81
    // handle_prio_id(Priority, Vec<SongId>),
82
    // handle_range_id(SongId, WindowRange),
83
    // handle_shuffle(Option<OneOrRange>),
84
    // handle_swap(SongPosition, SongPosition),
85
    // handle_swap_id(SongId, SongId),
86
    // handle_add_tag_id(SongId, TagName, TagValue),
87
    // handle_clear_tag_id(SongId, TagName),
88

            
89
    // // -- Stored Playlist Commands -- //
90
    // ListPlaylist(PlaylistName, Option<WindowRange>),
91
    // ListPlaylistInfo(PlaylistName, Option<WindowRange>),
92
    // SearchPlaylist(PlaylistName, Filter, Option<WindowRange>),
93
    // ListPlaylists,
94
    // Load(PlaylistName, Option<WindowRange>, SongPosition),
95
    // PlaylistAdd(PlaylistName, Uri, SongPosition),
96
    // PlaylistClear(PlaylistName),
97
    // PlaylistDelete(PlaylistName, OneOrRange),
98
    // PlaylistLength(PlaylistName),
99
    // // TODO: which type of range?
100
    // PlaylistMove(PlaylistName, OneOrRange, SongPosition),
101
    // Rename(PlaylistName, PlaylistName),
102
    // Rm(PlaylistName),
103
    // Save(PlaylistName, Option<SaveMode>),
104

            
105
    // // -- Music Database Commands -- //
106
    // AlbumArt(Uri, Offset),
107
    // Count(Filter, Option<GroupType>),
108
    // GetFingerprint(Uri),
109
    // Find(Filter, Option<Sort>, Option<WindowRange>),
110
    // FindAdd(Filter, Option<Sort>, Option<WindowRange>, Option<SongPosition>),
111
    // List(Tag, Filter, Option<GroupType>),
112
    // #[deprecated]
113
    // ListAll(Option<Uri>),
114
    // #[deprecated]
115
    // ListAllInfo(Option<Uri>),
116
    // ListFiles(Uri),
117
    // LsInfo(Option<Uri>),
118
    // ReadComments(Uri),
119
    // ReadPicture(Uri, Offset),
120
    // Search(Filter, Option<Sort>, Option<WindowRange>),
121
    // SearchAdd(Filter, Option<Sort>, Option<WindowRange>, Option<SongPosition>),
122
    // SearchAddPl(Filter, Option<Sort>, Option<WindowRange>, Option<SongPosition>),
123
    // SearchCount(Filter, Option<GroupType>),
124
    // Update(Option<Uri>),
125
    // Rescan(Option<Uri>),
126

            
127
    // // -- Mount and Neighbor Commands -- //
128
    // Mount(Option<Path>, Option<Uri>),
129
    // Unmount(Path),
130
    // ListMounts,
131
    // ListNeighbors,
132

            
133
    // // -- Sticker Commands -- //
134
    // StickerGet(StickerType, Uri, String),
135
    // StickerSet(StickerType, Uri, String, String),
136
    // StickerDelete(StickerType, Uri, String),
137
    // StickerList(StickerType, Uri),
138
    // StickerFind(StickerType, Uri, String, Option<Sort>, Option<WindowRange>),
139
    // StickerFindValue(StickerType, Uri, String, String, Option<Sort>, Option<WindowRange>),
140
    // StickerNames,
141
    // StickerTypes,
142
    // StickerNamesTypes(Option<StickerType>),
143

            
144
    // // -- Connection Commands -- //
145
    // Close,
146
    // Kill,
147
    // Password(String),
148
    // Ping,
149
    // BinaryLimit(u64),
150
    // TagTypes,
151
    // TagTypesDisable(Vec<Tag>),
152
    // TagTypesEnable(Vec<Tag>),
153
    // TagTypesClear,
154
    // TagTypesAll,
155
    // TagTypesAvailable,
156
    // TagTypesReset(Vec<Tag>),
157
    // Protocol,
158
    // ProtocolDisable(Vec<Feature>),
159
    // ProtocolEnable(Vec<Feature>),
160
    // ProtocolClear,
161
    // ProtocolAll,
162
    // ProtocolAvailable,
163

            
164
    // // -- Partition Commands -- //
165
    // Partition(PartitionName),
166
    // ListPartitions,
167
    // NewPartition(PartitionName),
168
    // DelPartition(PartitionName),
169
    // MoveOutput(String),
170

            
171
    // // -- Audio Output Commands -- //
172
    // DisableOutput(AudioOutputId),
173
    // EnableOutput(AudioOutputId),
174
    // ToggleOutput(AudioOutputId),
175
    // Outputs,
176
    // OutputSet(AudioOutputId, String, String),
177

            
178
    // // -- Reflection Commands -- //
179
    // Config,
180
    // Commands,
181
    // NotCommands,
182
    // UrlHandlers,
183
    // Decoders,
184

            
185
    // // -- Client to Client Commands -- //
186
    // Subscribe(ChannelName),
187
    // Unsubscribe(ChannelName),
188
    // Channels,
189
    // ReadMessages,
190
    // SendMessage(ChannelName, String),
191
}
192

            
193
// impl Into<Vec<u8>> for Request {
194
//     fn into(self) -> Vec<u8> {
195
//         todo!()
196
//     }
197
// }
198

            
199
// #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
200
// pub enum SaveMode {
201
//   Create,
202
//   Append,
203
//   Replace,
204
// }
205

            
206
// #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
207
// pub enum SeekMode {
208
//   Relative,
209
//   RelativeReverse,
210
//   Absolute,
211
// }
212

            
213
// #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
214
// pub enum SubSystem {
215
//   /// The song database has been modified after update.
216
//   Database,
217
//   /// A database update has started or finished. If the database was modified during the update, the database event is also emitted.
218
//   Update,
219
//   /// A stored playlist has been modified, renamed, created or deleted
220
//   StoredPlaylist,
221
//   /// The queue (i.e. the current playlist) has been modified
222
//   Playlist,
223
//   /// The player has been started, stopped or seeked or tags of the currently playing song have changed (e.g. received from stream)
224
//   Player,
225
//   /// The volume has been changed
226
//   Mixer,
227
//   /// An audio output has been added, removed or modified (e.g. renamed, enabled or disabled)
228
//   Output,
229
//   /// Options like repeat, random, crossfade, replay gain
230
//   Options,
231
//   /// A partition was added, removed or changed
232
//   Partition,
233
//   /// The sticker database has been modified.
234
//   Sticker,
235
//   /// A client has subscribed or unsubscribed to a channel
236
//   Subscription,
237
//   /// A message was received on a channel this client is subscribed to; this event is only emitted when the client’s message queue is empty
238
//   Message,
239
//   /// A neighbor was found or lost
240
//   Neighbor,
241
//   /// The mount list has changed
242
//   Mount,
243

            
244
//   /// Other subsystems not covered by the above
245
//   Other(String),
246
// }