use bytes::Bytes;
use serde::de::DeserializeOwned;
use crate::error::Result;
#[derive(Debug)]
pub struct EndpointReply {
inner: reqwest::Response,
}
impl EndpointReply {
pub(crate) fn new(inner: reqwest::Response) -> Self {
Self { inner }
}
pub async fn json<R: DeserializeOwned>(self) -> Result<R> {
Ok(self.inner.json::<R>().await?)
}
pub async fn bytes(self) -> Result<Bytes> {
Ok(self.inner.bytes().await?)
}
pub async fn text(self) -> Result<String> {
Ok(self.inner.text().await?)
}
pub fn status(&self) -> u16 {
self.inner.status().as_u16()
}
#[doc(hidden)]
pub fn into_inner(self) -> reqwest::Response {
self.inner
}
}