Crates.io | bluos-api-rs |
lib.rs | bluos-api-rs |
version | 1.1.2 |
source | src |
created_at | 2022-02-05 04:28:36.45281 |
updated_at | 2024-04-29 23:14:41.943223 |
description | BluOS API wrappers for Rust |
homepage | |
repository | https://github.com/coral/bluos-api-rs |
max_upload_size | |
id | 527264 |
size | 71,596 |
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.