use bytes::Bytes;
use snafu::ResultExt;
use crate::Error;
pub trait FromHttpResponse {
fn from_http_response(http_response: http::Response<Bytes>) -> Result<Self, Error>
where
Self: Sized;
}
#[cfg(feature = "serde")]
impl<D> FromHttpResponse for D
where
D: serde::de::DeserializeOwned,
{
fn from_http_response(http_response: http::Response<Bytes>) -> Result<Self, Error> {
serde_json::from_slice(http_response.body()).context(crate::error::JsonSnafu)
}
}