moosync_edk/
response_utils.rs1use extensions_proto::moosync::types::PlayerState;
2use extensions_proto::moosync::types::*;
3use extensions_proto::struct_proto::google::protobuf::Struct as ProtoStruct;
4use songs_proto::moosync::types::{Song, EntityResult};
5
6pub trait Extract<T> {
7 fn extract(self) -> T;
8}
9
10impl Extract<Vec<Song>> for GetSongResponse {
11 fn extract(self) -> Vec<Song> {
12 self.songs
13 }
14}
15
16impl Extract<Option<Song>> for GetCurrentSongResponse {
17 fn extract(self) -> Option<Song> {
18 self.song
19 }
20}
21
22impl Extract<PlayerState> for GetPlayerStateResponse {
23 fn extract(self) -> PlayerState {
24 self.state()
25 }
26}
27
28impl Extract<f64> for GetVolumeResponse {
29 fn extract(self) -> f64 {
30 self.volume
31 }
32}
33
34impl Extract<f64> for GetTimeResponse {
35 fn extract(self) -> f64 {
36 self.time
37 }
38}
39
40impl Extract<PreferenceData> for GetPreferenceResponse {
41 fn extract(self) -> PreferenceData {
42 self.data.unwrap_or_default()
43 }
44}
45
46impl Extract<PreferenceData> for GetSecureResponse {
47 fn extract(self) -> PreferenceData {
48 self.data.unwrap_or_default()
49 }
50}
51
52impl Extract<String> for AddPlaylistResponse {
53 fn extract(self) -> String {
54 self.playlist_id
55 }
56}
57
58impl Extract<Option<EntityResult>> for GetEntityResponse {
59 fn extract(self) -> Option<EntityResult> {
60 self.entity
61 }
62}
63
64impl Extract<Option<ProtoStruct>> for GetQueueResponse {
65 fn extract(self) -> Option<ProtoStruct> {
66 self.queue
67 }
68}