From 584a56c408d5d8b109b0abea4eaa8371dad0cd8f Mon Sep 17 00:00:00 2001 From: Ingvar Stepanyan Date: Mon, 16 Sep 2024 11:05:53 +0100 Subject: [PATCH] Convert JSON error to eyre early --- src/client/response.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/client/response.rs b/src/client/response.rs index 6440d82..94ef415 100644 --- a/src/client/response.rs +++ b/src/client/response.rs @@ -8,12 +8,12 @@ use serde::de::DeserializeOwned; use serde::{Deserialize, Deserializer}; trait FromJsonBytes: Sized { - fn from_json_bytes(bytes: &[u8]) -> serde_json::Result; + fn from_json_bytes(bytes: &[u8]) -> eyre::Result; } impl FromJsonBytes for T { - fn from_json_bytes(bytes: &[u8]) -> serde_json::Result { - serde_json::from_slice(bytes) + fn from_json_bytes(bytes: &[u8]) -> eyre::Result { + Ok(serde_json::from_slice(bytes)?) } } @@ -21,7 +21,7 @@ impl FromJsonBytes for T { struct Flattened(pub(crate) A, pub(crate) B); impl FromJsonBytes for Flattened { - fn from_json_bytes(bytes: &[u8]) -> serde_json::Result { + fn from_json_bytes(bytes: &[u8]) -> eyre::Result { Ok(Self(A::from_json_bytes(bytes)?, B::from_json_bytes(bytes)?)) } }