so://phie

verbal

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

blob: 88209e62717831d52e0fb8f60d5247b70212c5ca (3934 bytes)[doc][blame][raw]

1use serde::Serialize;

2use diesel::Queryable;

3

4#[derive(Debug, Serialize, Queryable)]

5pub struct Account {

6 pub id: i32,

7 pub username: Option<String>,

8 pub language: String,

9 pub is_playback_history: bool,

10}

11

12#[derive(Debug, Serialize, Queryable)]

13pub struct Device {

14 pub id: i32,

15 pub token: String,

16 pub account_id: i32,

17}

18

19#[derive(Debug, Serialize, Queryable)]

20pub struct Station {

21 pub id: i32,

22 pub uuid: String,

23 pub name: String,

24 pub stream_url: String,

25 pub votes: i32,

26 pub favicon: Option<String>,

27 pub homepage: Option<String>,

28 pub tags: Vec<String>,

29 pub country: Option<String>,

30 pub languages: Vec<String>,

31 pub state: Option<String>,

32}

33

34// use rand::{distributions::Alphanumeric, Rng};

35

36// #[derive(Debug, Deserialize, Serialize, FromRow)]

37// pub struct Account {

38// pub username: Option<String>,

39// pub language: String,

40// pub is_playback_history: bool,

41// }

42

43// impl Default for Account {

44// fn default() -> Self {

45// Self {

46// username: None,

47// language: "en".into(),

48// is_playback_history: true,

49// }

50// }

51// }

52

53// impl Query for Account {

54// fn into_keys(&self) -> String {

55// format!("

56// username,

57// language,

58// is_playback_history,

59// ")

60// }

61// fn into_values(&self) -> String {

62// format!(

63// "

64// {},

65// '{}',

66// {},

67// ",

68// Utils::null(&self.username),

69// &self.language,

70// &self.is_playback_history,

71// )

72// }

73// fn into_update(&self) -> String {

74// format!(

75// "

76// username = {},

77// language = '{}',

78// is_playback_history = {},

79// ",

80// Utils::null(&self.username),

81// &self.language,

82// &self.is_playback_history,

83// )

84// }

85// }

86

87// #[derive(Debug, Deserialize, Serialize, FromRow)]

88// pub struct Favorite {

89// pub station_id: String,

90// pub account_id: i32,

91// }

92

93// impl Favorite {

94// pub fn new(station_id: &str, account_id: i32) -> Self {

95// Self { station_id: station_id.into(), account_id }

96// }

97// }

98

99// impl Query for Favorite {

100// fn into_keys(&self) -> String {

101// format!("

102// station_id,

103// account_id,

104// ")

105// }

106// fn into_values(&self) -> String {

107// format!(

108// "

109// '{}',

110// {},

111// ",

112// &self.station_id,

113// &self.account_id,

114// )

115// }

116// fn into_update(&self) -> String {

117// format!(

118// "

119// station_id = '{}',

120// account_id = {},

121// ",

122// &self.station_id,

123// &self.account_id,

124// )

125// }

126// }

127

128// #[derive(Debug, Default, Deserialize, Serialize)]

129// pub struct Station {

130// pub id: String,

131// pub name: String,

132// pub stream_url: String,

133// pub votes: i64,

134// pub favicon: String,

135// pub homepage: String,

136// pub tags: Vec<String>,

137// pub click_trend: i64,

138// pub click_count: i64,

139// pub country: String,

140// pub languages: Vec<String>,

141// pub state: String,

142// pub is_favorite: bool,

143// }

144

145// #[derive(Debug, Deserialize, Serialize, FromRow)]

146// pub struct Code {

147// pub code: String,

148// pub used: bool,

149// pub expired: bool,

150// }

151

152// impl Code {

153// pub fn new() -> Self {

154// let code = rand::thread_rng()

155// .sample_iter(&Alphanumeric)

156// .take(6)

157// .map(char::from)

158// .map(|c| c.to_uppercase().to_string())

159// .collect::<String>();

160// Self { code, used: false, expired: false }

161// }

162// }