use crate::{common::SubSystem, Request, Response}; pub trait MPDServer { type Error; fn route_request(&mut self, request: Request) -> Result { match request { Request::ClearError => self.handle_clear_error().map(|_| Response::Ok), Request::CurrentSong => self.handle_current_song().map(|_| Response::Ok), Request::Idle(subsystems) => self.handle_idle(subsystems).map(|_| Response::Ok), Request::Status => self.handle_status().map(|_| Response::Ok), Request::Stats => self.handle_stats().map(|_| Response::Ok), _ => unimplemented!(), } } fn handle_unimplemented(&mut self) -> Result<(), Self::Error> { // fn handle_unimplemented(&mut self, name: &str) -> Result<(), Self::Error> { // return Err("a".into()); unimplemented!() } // -- Query Commands -- // fn handle_clear_error(&mut self) -> Result<(), Self::Error> { self.handle_unimplemented() } fn handle_current_song(&mut self) -> Result<(), Self::Error> { self.handle_unimplemented() } fn handle_idle(&mut self, _: Option>) -> Result<(), Self::Error> { self.handle_unimplemented() } fn handle_status(&mut self) -> Result<(), Self::Error> { self.handle_unimplemented() } fn handle_stats(&mut self) -> Result<(), Self::Error> { self.handle_unimplemented() } // -- Playback Commands -- // // handle_consume(ConsumeState), // handle_crossfade(Seconds), // handle_mix_ramp_db(f32), // handle_mix_ramp_delay(Seconds), // handle_random(bool), // handle_repeat(bool), // handle_set_vol(Volume), // handle_get_vol, // handle_single(SingleState), // handle_replay_gain_mode(ReplayGainMode), // handle_replay_gain_status, // handle_volume(Volume), // // -- Playback Control Commands -- // // next, // pause(Option), // play(SongPosition), // play_id(SongId), // previous, // seek(SongPosition, TimeWithFractions), // seek_id(SongId, TimeWithFractions), // seek_cur(SeekMode, TimeWithFractions), // stop, // // -- Queue Commands -- // // handle_add(String, Option), // handle_add_id(String, Option), // handle_clear, // handle_delete(OneOrRange), // handle_delete_id(SongId), // handle_move(OneOrRange, SongPosition), // handle_move_id(SongId, SongPosition), // handle_playlist, // handle_playlist_find(Filter, Option, Option), // handle_playlist_id(SongId), // handle_playlist_info(OneOrRange), // handle_playlist_search(Filter, Option, Option), // handle_pl_changes(Version, Option), // handle_pl_changes_pos_id(Version, Option), // handle_prio(Priority, WindowRange), // handle_prio_id(Priority, Vec), // handle_range_id(SongId, WindowRange), // handle_shuffle(Option), // handle_swap(SongPosition, SongPosition), // handle_swap_id(SongId, SongId), // handle_add_tag_id(SongId, TagName, TagValue), // handle_clear_tag_id(SongId, TagName), // // -- Stored Playlist Commands -- // // ListPlaylist(PlaylistName, Option), // ListPlaylistInfo(PlaylistName, Option), // SearchPlaylist(PlaylistName, Filter, Option), // ListPlaylists, // Load(PlaylistName, Option, SongPosition), // PlaylistAdd(PlaylistName, Uri, SongPosition), // PlaylistClear(PlaylistName), // PlaylistDelete(PlaylistName, OneOrRange), // PlaylistLength(PlaylistName), // // TODO: which type of range? // PlaylistMove(PlaylistName, OneOrRange, SongPosition), // Rename(PlaylistName, PlaylistName), // Rm(PlaylistName), // Save(PlaylistName, Option), // // -- Music Database Commands -- // // AlbumArt(Uri, Offset), // Count(Filter, Option), // GetFingerprint(Uri), // Find(Filter, Option, Option), // FindAdd(Filter, Option, Option, Option), // List(Tag, Filter, Option), // #[deprecated] // ListAll(Option), // #[deprecated] // ListAllInfo(Option), // ListFiles(Uri), // LsInfo(Option), // ReadComments(Uri), // ReadPicture(Uri, Offset), // Search(Filter, Option, Option), // SearchAdd(Filter, Option, Option, Option), // SearchAddPl(Filter, Option, Option, Option), // SearchCount(Filter, Option), // Update(Option), // Rescan(Option), // // -- Mount and Neighbor Commands -- // // Mount(Option, Option), // Unmount(Path), // ListMounts, // ListNeighbors, // // -- Sticker Commands -- // // StickerGet(StickerType, Uri, String), // StickerSet(StickerType, Uri, String, String), // StickerDelete(StickerType, Uri, String), // StickerList(StickerType, Uri), // StickerFind(StickerType, Uri, String, Option, Option), // StickerFindValue(StickerType, Uri, String, String, Option, Option), // StickerNames, // StickerTypes, // StickerNamesTypes(Option), // // -- Connection Commands -- // // Close, // Kill, // Password(String), // Ping, // BinaryLimit(u64), // TagTypes, // TagTypesDisable(Vec), // TagTypesEnable(Vec), // TagTypesClear, // TagTypesAll, // TagTypesAvailable, // TagTypesReset(Vec), // Protocol, // ProtocolDisable(Vec), // ProtocolEnable(Vec), // ProtocolClear, // ProtocolAll, // ProtocolAvailable, // // -- Partition Commands -- // // Partition(PartitionName), // ListPartitions, // NewPartition(PartitionName), // DelPartition(PartitionName), // MoveOutput(String), // // -- Audio Output Commands -- // // DisableOutput(AudioOutputId), // EnableOutput(AudioOutputId), // ToggleOutput(AudioOutputId), // Outputs, // OutputSet(AudioOutputId, String, String), // // -- Reflection Commands -- // // Config, // Commands, // NotCommands, // UrlHandlers, // Decoders, // // -- Client to Client Commands -- // // Subscribe(ChannelName), // Unsubscribe(ChannelName), // Channels, // ReadMessages, // SendMessage(ChannelName, String), } // impl Into> for Request { // fn into(self) -> Vec { // todo!() // } // } // #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] // pub enum SaveMode { // Create, // Append, // Replace, // } // #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] // pub enum SeekMode { // Relative, // RelativeReverse, // Absolute, // } // #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] // pub enum SubSystem { // /// The song database has been modified after update. // Database, // /// A database update has started or finished. If the database was modified during the update, the database event is also emitted. // Update, // /// A stored playlist has been modified, renamed, created or deleted // StoredPlaylist, // /// The queue (i.e. the current playlist) has been modified // Playlist, // /// The player has been started, stopped or seeked or tags of the currently playing song have changed (e.g. received from stream) // Player, // /// The volume has been changed // Mixer, // /// An audio output has been added, removed or modified (e.g. renamed, enabled or disabled) // Output, // /// Options like repeat, random, crossfade, replay gain // Options, // /// A partition was added, removed or changed // Partition, // /// The sticker database has been modified. // Sticker, // /// A client has subscribed or unsubscribed to a channel // Subscription, // /// 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 // Message, // /// A neighbor was found or lost // Neighbor, // /// The mount list has changed // Mount, // /// Other subsystems not covered by the above // Other(String), // }