inline that one fixup method
This commit is contained in:
parent
9f97a2cae3
commit
6892f99070
1 changed files with 7 additions and 12 deletions
|
@ -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> {
|
||||
|
|
Loading…
Reference in a new issue