radiobrowser-lib-rust/README.md

73 lines
1.8 KiB
Markdown
Raw Normal View History

2022-04-18 21:56:20 +00:00
# Radiobrowser Lib Rust
Client library for radio-browser.info and other radio-browser-rust servers
2022-05-06 21:18:52 +00:00
## Features
- [x] Async / Blocking API
- [x] Clean query api with builder pattern
- [x] Countries, languages, tags, stations, serverconfig
- [x] Server statistics
- [x] Station actions: click, vote
- [ ] Add streams
2022-05-12 20:42:44 +00:00
## Crate features
* "blocking" - support for non-async (blocking) mode
2022-09-14 06:56:42 +00:00
* "chrono" - return DateTime objects instead of strings
2022-05-12 20:42:44 +00:00
2022-05-06 21:18:52 +00:00
## Getting started (Blocking)
### Example:
It needs to have the feature "blocking" enabled.
Cargo.toml entry:
```toml
radiobrowser = { version = "*", features = ["blocking"] }
```
```rust
use radiobrowser::blocking::RadioBrowserAPI;
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
2023-10-05 19:06:11 +00:00
let mut api = RadioBrowserAPI::new()?;
2023-10-20 18:48:33 +00:00
let servers = RadioBrowserAPI::get_default_servers()?;
2022-05-06 21:18:52 +00:00
println!("Servers: {:?}", servers);
2023-10-05 19:06:11 +00:00
let status = api.get_server_status()?;
2022-05-06 21:18:52 +00:00
println!("Status: {:?}", status);
let countries = api.get_countries().send()?;
println!("Countries: {:?}", countries);
let stations = api.get_stations().name("jazz").send()?;
println!("Stations: {:?}", stations);
Ok(())
}
```
## Getting started (Async)
2022-04-21 20:59:15 +00:00
Cargo.toml entry
```toml
radiobrowser = "*"
2022-04-18 21:56:20 +00:00
```
2022-05-06 21:18:52 +00:00
### Example:
2022-04-21 20:59:15 +00:00
```rust
use radiobrowser::RadioBrowserAPI;
use radiobrowser::StationOrder;
use std::error::Error;
#[async_std::main]
async fn main() -> Result<(), Box<dyn Error>> {
let mut api = RadioBrowserAPI::new().await?;
let stations = api
.get_stations()
.name("jazz")
.reverse(true)
.order(StationOrder::Clickcount)
2022-04-21 21:03:49 +00:00
.send()
.await?;
2022-04-21 20:59:15 +00:00
println!("Stations found: {}", stations?.len());
Ok(())
}
2022-04-18 21:56:20 +00:00
```
## Usage
2022-04-21 20:59:15 +00:00
Documentation is at https://docs.rs/radiobrowser
2022-04-18 21:56:20 +00:00
## License
2022-04-21 20:59:15 +00:00
This project is MIT licensed.