radiobrowser-lib-rust/examples/test-async.rs

42 lines
1.6 KiB
Rust
Raw Normal View History

2022-05-06 21:18:52 +00:00
use futures::join;
use radiobrowser::RadioBrowserAPI;
2023-10-20 19:07:41 +00:00
use radiobrowser::RbError;
2022-05-06 21:18:52 +00:00
use radiobrowser::StationOrder;
#[async_std::main]
2023-10-20 19:07:41 +00:00
async fn main() -> Result<(), RbError> {
2022-05-06 21:18:52 +00:00
let mut api = RadioBrowserAPI::new().await?;
let countries = api.get_countries().send();
let languages = api.get_languages().send();
let tags = api.get_tags().filter("jazz").send();
let stations = api
.get_stations()
.name("jazz")
.reverse(true)
.order(StationOrder::Clickcount)
.send();
let mut api2 = api.clone();
let config = api.get_server_config();
let stats = api2.get_server_status();
let (stations, config, countries, languages, tags, stats) = join!(stations, config, countries, languages, tags, stats);
println!("Config: {:#?}", config?);
println!("Status: {:#?}", stats?);
println!("Countries found: {}", countries?.len());
println!("Languages found: {}", languages?.len());
let tags = tags?;
println!("Tags found: {}", tags.len());
println!("{:?}", tags);
let stations = stations?;
println!("Stations found: {}", stations.len());
2022-05-12 20:42:44 +00:00
println!("First found station: {:#?}", stations[0]);
println!("First found station: {:#?}", stations[0].clicktimestamp_iso8601);
2022-05-06 21:18:52 +00:00
let vote_result = api.station_vote(&stations[0].stationuuid).await?;
println!("Stations voted result: {:?}", vote_result);
let click_result = api.station_click(&stations[0].stationuuid).await?;
println!("Stations clicked result: {:?}", click_result);
2023-01-27 22:43:42 +00:00
let station_changes = api.get_station_changes(1,None).await?;
println!("Station changes result: {:#?}", station_changes);
2022-05-06 21:18:52 +00:00
Ok(())
}