mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
21 lines
622 B
Rust
21 lines
622 B
Rust
use crate::MetadataError;
|
|
|
|
use librespot_core::{Error, Session};
|
|
|
|
pub type RequestResult = Result<bytes::Bytes, Error>;
|
|
|
|
#[async_trait]
|
|
pub trait MercuryRequest {
|
|
async fn request(session: &Session, uri: &str) -> RequestResult {
|
|
let request = session.mercury().get(uri)?;
|
|
let response = request.await?;
|
|
match response.payload.first() {
|
|
Some(data) => {
|
|
let data = data.to_vec().into();
|
|
trace!("Received metadata: {:?}", data);
|
|
Ok(data)
|
|
}
|
|
None => Err(Error::unavailable(MetadataError::Empty)),
|
|
}
|
|
}
|
|
}
|