From 6892f99070841a7cfa21aa6ba4a7a0f315fff3b2 Mon Sep 17 00:00:00 2001 From: Erica Z Date: Fri, 1 Nov 2024 09:59:32 +0100 Subject: [PATCH] inline that one fixup method --- src/subsonic.rs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/subsonic.rs b/src/subsonic.rs index 00bc6ff..8cd71f6 100644 --- a/src/subsonic.rs +++ b/src/subsonic.rs @@ -7,15 +7,6 @@ fn runtime() -> &'static tokio::runtime::Runtime { }) } -impl schema::SubsonicResponse { - fn fixup(self) -> Result { - 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::>() .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> {