#![allow(clippy::result_large_err)]
use audd::{handle_callback, AudDError, CallbackEvent};
#[tokio::main]
async fn main() -> Result<(), AudDError> {
let raw_body: &[u8] = br#"{
"status": "success",
"result": {
"radio_id": 7,
"timestamp": "2026-05-04 10:31:43",
"play_length": 111,
"results": [
{
"artist": "Alan Walker, A$AP Rocky",
"title": "Live Fast (PUBGM)",
"score": 100
}
]
}
}"#;
match handle_callback(raw_body)? {
CallbackEvent::Match(m) => {
println!(
"[match] radio_id={} {} — {}",
m.radio_id, m.song.artist, m.song.title,
);
for alt in &m.alternatives {
println!(" alternative: {} — {}", alt.artist, alt.title);
}
}
CallbackEvent::Notification(n) => {
println!(
"[notification] radio_id={} code={} {}",
n.radio_id, n.notification_code, n.notification_message,
);
}
}
Ok(())
}