1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-11-21 23:00:50 +03:00

Apply suggestions from code review

Co-authored-by: Kévin Commaille <76261501+zecakeh@users.noreply.github.com>
This commit is contained in:
Quentin Gliech
2022-08-19 10:07:15 +02:00
parent 185ff622f9
commit 95eba8f88b
3 changed files with 9 additions and 9 deletions

View File

@@ -38,4 +38,4 @@ tower = { version = "0.4.13", features = ["util"] }
[features] [features]
default = [] default = []
axum = ["dep:axum"] axum = ["dep:axum"]
client = ["dep:hyper-rustls", "hyper/tcp", "tokio", "tokio/sync", "tokio/parking_lot"] client = ["dep:hyper-rustls", "hyper/tcp", "dep:tokio", "tokio?/sync", "tokio?/parking_lot"]

View File

@@ -32,7 +32,7 @@ pub enum Error<Service> {
Service { inner: Service }, Service { inner: Service },
#[error("could not serialize JSON payload")] #[error("could not serialize JSON payload")]
Json { Serialize {
#[source] #[source]
inner: serde_json::Error, inner: serde_json::Error,
}, },
@@ -43,8 +43,8 @@ impl<S> Error<S> {
Self::Service { inner: source } Self::Service { inner: source }
} }
fn json(source: serde_json::Error) -> Self { fn serialize(source: serde_json::Error) -> Self {
Self::Json { inner: source } Self::Serialize { inner: source }
} }
} }
@@ -88,7 +88,7 @@ where
let body = match serde_json::to_vec(&body) { let body = match serde_json::to_vec(&body) {
Ok(body) => Full::new(Bytes::from(body)), Ok(body) => Full::new(Bytes::from(body)),
Err(err) => return std::future::ready(Err(Error::json(err))).left_future(), Err(err) => return std::future::ready(Err(Error::serialize(err))).left_future(),
}; };
let request = Request::from_parts(parts, body); let request = Request::from_parts(parts, body);

View File

@@ -27,7 +27,7 @@ pub enum Error<Service> {
Service { inner: Service }, Service { inner: Service },
#[error("could not parse JSON payload")] #[error("could not parse JSON payload")]
Serialize { Deserialize {
#[source] #[source]
inner: serde_json::Error, inner: serde_json::Error,
}, },
@@ -38,8 +38,8 @@ impl<S> Error<S> {
Self::Service { inner: source } Self::Service { inner: source }
} }
fn serialize(source: serde_json::Error) -> Self { fn deserialize(source: serde_json::Error) -> Self {
Self::Serialize { inner: source } Self::Deserialize { inner: source }
} }
} }
@@ -85,7 +85,7 @@ where
let response = res.map_err(Error::service)?; let response = res.map_err(Error::service)?;
let (parts, body) = response.into_parts(); let (parts, body) = response.into_parts();
let body = serde_json::from_reader(body.reader()).map_err(Error::serialize)?; let body = serde_json::from_reader(body.reader()).map_err(Error::deserialize)?;
let res = Response::from_parts(parts, body); let res = Response::from_parts(parts, body);
Ok(res) Ok(res)