A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
blob: ee2aed8907658cf887e5063a98b61e097c034363 (2059 bytes)[doc][blame][raw]
1
use serde::Deserialize;2
use serde::Serialize;4
use crate::model;5
use crate::rest;6
use crate::utils::to_array;7
use crate::utils::upgrade_to_https;9
#[derive(Debug, Default, Deserialize)]10
pub struct Song {11
pub url: String,12
}14
#[derive(Debug, Serialize)]15
pub struct Account {16
pub username: Option<String>,17
pub language: String,18
pub is_playback_history: bool,19
}21
impl From<model::Account> for Account {22
fn from(model: model::Account) -> Self {23
Self {24
username: model.username,25
language: model.language,26
is_playback_history: model.is_playback_history,27
}28
}29
}31
#[derive(Debug, Serialize)]32
pub struct Station {33
pub uuid: String,34
pub name: String,35
pub stream_url: String,36
pub votes: i32,37
pub favicon: Option<String>,38
pub homepage: Option<String>,39
pub tags: Vec<String>,40
pub country: Option<String>,41
pub languages: Vec<String>,42
pub state: Option<String>,43
pub is_favorite: bool,44
}46
impl From<model::Station> for Station {47
fn from(model: model::Station) -> Self {48
Self {49
uuid: model.uuid,50
name: model.name,51
stream_url: upgrade_to_https(model.stream_url),52
votes: model.votes,53
favicon: model.favicon,54
homepage: model.homepage,55
tags: model.tags,56
country: model.country,57
languages: model.languages,58
state: model.state,59
is_favorite: false,60
}61
}62
}64
impl From<rest::Station> for Station {65
fn from(rest: rest::Station) -> Self {66
Self {67
uuid: rest.stationuuid,68
name: rest.name,69
stream_url: upgrade_to_https(rest.url),70
votes: rest.votes,71
favicon: Some(rest.favicon),72
homepage: Some(rest.homepage),73
tags: to_array(rest.tags),74
country: Some(rest.countrycode),75
languages: to_array(rest.languagecodes),76
state: Some(rest.state),77
is_favorite: false,78
}79
}80
}