A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
62
}63
match successful_response {64
Some(response) => Ok(response),65
None => return Err(Error::new(ErrorKind::Fetch, "All request attempts failed!")),65
None => Err(Error::new(ErrorKind::Fetch, "All request attempts failed!")),66
}67
}68
}
1
use serde::Serialize;3
use crate::model;4
use crate::rest;5
use crate::utils::to_array;6
use crate::utils::upgrade_to_https;8
#[derive(Debug, Serialize)]
12
pub is_playback_history: bool,13
}13
impl Into<Account> for model::Account {14
fn into(self) -> Account {15
Account {16
username: self.username,17
language: self.language,18
is_playback_history: self.is_playback_history,15
impl 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
}
37
pub is_favorite: bool,38
}38
impl Into<Station> for model::Station {39
fn into(self) -> Station {40
Station {41
uuid: self.uuid,42
name: self.name,43
stream_url: upgrade_to_https(self.stream_url),44
votes: self.votes,45
favicon: self.favicon,46
homepage: self.homepage,47
tags: self.tags,48
country: self.country,49
languages: self.languages,50
state: self.state,40
impl 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
}58
impl 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
}
1
use serde::Deserialize;3
use crate::data;4
use crate::utils::{to_array, upgrade_to_https};3
#[derive(Debug, Clone, Deserialize)]4
pub struct Station {5
pub stationuuid: String,
13
pub languagecodes: String,14
pub state: String,15
}20
impl Into<data::Station> for Station {21
fn into(self) -> data::Station {22
data::Station {23
uuid: self.stationuuid,24
name: self.name,25
stream_url: upgrade_to_https(self.url),26
votes: self.votes,27
favicon: Some(self.favicon),28
homepage: Some(self.homepage),29
tags: to_array(self.tags),30
country: Some(self.countrycode),31
languages: to_array(self.languagecodes),32
state: Some(self.state),33
is_favorite: false,34
}35
}36
}
5
#[tokio::main]6
async fn main() {7
let database_url = "postgres://typable:De24Si98@192.168.2.3:9748/verbal?sslmode=disable";8
let pool = PgPool::connect(&database_url).await.unwrap();8
let pool = PgPool::connect(database_url).await.unwrap();9
let accounts = sqlx::query_as::<_, model::Account>("SELECT * FROM account")10
.fetch_all(&pool)11
.await
3
pub fn to_array(value: String) -> Vec<String> {4
value5
.split(",")5
.split(',')6
.map(str::to_string)7
.filter(|tag| tag.trim().len() > 0)7
.filter(|tag| !tag.trim().is_empty())8
.collect::<Vec<String>>()9
}