4 stable releases
1.1.2 | Apr 29, 2024 |
---|---|
1.1.1 | Feb 5, 2022 |
1.0.0 | Feb 5, 2022 |
#690 in Web programming
26KB
473 lines
BluOS API wrappers for Rust
These are ergonomic wrappers around the BluOS semi-documented API. It ships with discovery using mDNS so you do not have to mess with finding out what the IP is for your BluOS device.
Why would you want this in Rust? Doesn't it make more sense to do something like this in Python or Node? Who would ever use this in Rust? GOOD QUESTIONS OFTEN LACKS GOOD ANSWERS
use anyhow::Result;
use bluos_api_rs::{BluOS, Discovery};
#[tokio::main]
async fn main() -> Result<()> {
// Find the first device in our network
let device = Discovery::discover_one().await?;
// Create a new BluOS device from the discovered address
let bluos = BluOS::new_from_discovered(device)?;
// Print the status
let status = bluos.status().await?;
dbg!(status);
// List items in the play queue
let playlist = bluos.queue(None).await?;
for n in playlist.entries {
println!("{}", n.title.unwrap_or_default());
}
// Resume playback
bluos.play().await?;
Ok(())
}
If you don't want Discovery & Tokio you can disable the discover
feature.
Dependencies
~4–16MB
~201K SLoC