so://phie

verbal

A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal

blob: 7519bd9f438dd32f8c7b88f4bbdc8fb62d36e551 (1954 bytes)[doc][blame][raw]

1use serde::Serialize;

2

3use crate::model;

4use crate::rest;

5use crate::utils::to_array;

6use crate::utils::upgrade_to_https;

7

8#[derive(Debug, Serialize)]

9pub struct Account {

10 pub username: Option<String>,

11 pub language: String,

12 pub is_playback_history: bool,

13}

14

15impl From<model::Account> for Account {

16 fn from(model: model::Account) -> Self {

17 Self {

18 username: model.username,

19 language: model.language,

20 is_playback_history: model.is_playback_history,

21 }

22 }

23}

24

25#[derive(Debug, Serialize)]

26pub struct Station {

27 pub uuid: String,

28 pub name: String,

29 pub stream_url: String,

30 pub votes: i32,

31 pub favicon: Option<String>,

32 pub homepage: Option<String>,

33 pub tags: Vec<String>,

34 pub country: Option<String>,

35 pub languages: Vec<String>,

36 pub state: Option<String>,

37 pub is_favorite: bool,

38}

39

40impl From<model::Station> for Station {

41 fn from(model: model::Station) -> Self {

42 Self {

43 uuid: model.uuid,

44 name: model.name,

45 stream_url: upgrade_to_https(model.stream_url),

46 votes: model.votes,

47 favicon: model.favicon,

48 homepage: model.homepage,

49 tags: model.tags,

50 country: model.country,

51 languages: model.languages,

52 state: model.state,

53 is_favorite: false,

54 }

55 }

56}

57

58impl From<rest::Station> for Station {

59 fn from(rest: rest::Station) -> Self {

60 Self {

61 uuid: rest.stationuuid,

62 name: rest.name,

63 stream_url: upgrade_to_https(rest.url),

64 votes: rest.votes,

65 favicon: Some(rest.favicon),

66 homepage: Some(rest.homepage),

67 tags: to_array(rest.tags),

68 country: Some(rest.countrycode),

69 languages: to_array(rest.languagecodes),

70 state: Some(rest.state),

71 is_favorite: false,

72 }

73 }

74}