Skip to main content

danceinterpreter_rs/dataloading/
displayable_data.rs

1use crate::dataloading::songinfo::SongInfo;
2use crate::dataloading::staticinfo::StaticInfo;
3
4#[derive(Default, Debug, Clone)]
5pub struct DisplayableData {
6    pub headline: String,
7    pub subline_upper: String,
8    pub subline_lower: String,
9    pub subline_image: Option<iced::widget::image::Handle>,
10}
11
12impl DisplayableData {
13    #[allow(dead_code)]
14    pub fn new(
15        headline: String,
16        subline_left: String,
17        subline_right: String,
18        subline_image: Option<iced::widget::image::Handle>,
19    ) -> Self {
20        Self {
21            headline,
22            subline_upper: subline_left,
23            subline_lower: subline_right,
24            subline_image,
25        }
26    }
27}
28
29impl From<SongInfo> for DisplayableData {
30    fn from(song_info: SongInfo) -> Self {
31        Self {
32            headline: song_info.dance,
33            subline_upper: song_info.title,
34            subline_lower: song_info.artist,
35            subline_image: song_info.album_art,
36        }
37    }
38}
39
40impl From<&SongInfo> for DisplayableData {
41    fn from(song_info: &SongInfo) -> Self {
42        let song_info = song_info.clone();
43        Self::from(song_info)
44    }
45}
46
47impl From<StaticInfo> for DisplayableData {
48    fn from(static_info: StaticInfo) -> Self {
49        Self {
50            headline: static_info.name,
51            subline_upper: String::new(),
52            subline_lower: String::new(),
53            subline_image: None,
54        }
55    }
56}
57
58impl From<&StaticInfo> for DisplayableData {
59    fn from(static_info: &StaticInfo) -> Self {
60        let static_info = static_info.clone();
61        Self::from(static_info)
62    }
63}