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