inline that one fixup method

This commit is contained in:
Erica Z 2024-11-01 09:59:32 +01:00
parent 9f97a2cae3
commit 6892f99070

View file

@ -7,15 +7,6 @@ fn runtime() -> &'static tokio::runtime::Runtime {
})
}
impl<T> schema::SubsonicResponse<T> {
fn fixup(self) -> Result<T, Error> {
match self {
Self::Ok { inner } => Ok(inner),
Self::Failed { error } => Err(Error::SubsonicError(error)),
}
}
}
#[derive(Debug)]
pub enum Error {
UrlParseError(url::ParseError),
@ -119,15 +110,19 @@ impl Client {
.expect("could not send subsonic response back to the main loop");
});
receiver
let response = receiver
.recv()
.await
.expect("could not receive subsonic response from tokio")?
.error_for_status()?
.json::<schema::SubsonicResponseOuter<T>>()
.await?
.subsonic_response
.fixup()
.subsonic_response;
match response {
schema::SubsonicResponse::Ok { inner } => Ok(inner),
schema::SubsonicResponse::Failed { error } => Err(Error::SubsonicError(error)),
}
}
pub async fn ping(&self) -> Result<(), Error> {