radiobrowser-lib-rust/src/bin/test.rs

30 lines
988 B
Rust
Raw Normal View History

2022-04-21 18:56:01 +00:00
use futures::join;
2022-04-21 20:47:23 +00:00
use radiobrowser::RadioBrowserAPI;
use radiobrowser::StationOrder;
2022-04-18 23:55:26 +00:00
use std::error::Error;
#[async_std::main]
async fn main() -> Result<(), Box<dyn Error>> {
2022-04-20 19:51:14 +00:00
let mut api = RadioBrowserAPI::new().await?;
2022-04-21 19:18:17 +00:00
let countries = api.get_countries().send();
let languages = api.get_languages().send();
2022-04-21 20:47:23 +00:00
let tags = api.get_tags().filter("jazz").send();
2022-04-21 18:56:01 +00:00
let stations = api
2022-04-21 19:18:17 +00:00
.get_stations()
2022-04-21 18:56:01 +00:00
.name("jazz")
.reverse(true)
.order(StationOrder::Clickcount)
.send();
let config = api.get_server_config();
2022-04-21 20:47:23 +00:00
let (stations, config, countries, languages, tags) = join!(stations, config, countries, languages, tags);
2022-04-21 18:56:01 +00:00
println!("Config: {:#?}", config?);
println!("Countries found: {}", countries?.len());
2022-04-21 19:18:17 +00:00
println!("Languages found: {}", languages?.len());
2022-04-21 20:47:23 +00:00
let tags = tags?;
println!("Tags found: {}", tags.len());
println!("{:?}", tags);
2022-04-21 18:56:01 +00:00
println!("Stations found: {}", stations?.len());
2022-04-18 23:55:26 +00:00
Ok(())
}