[ENHANCEMENT] Add support for raw/bytes response
dodomorandi opened this issue · 3 comments
Is your feature request related to a problem? Please describe.
ElasticSearch supports cbor
format, and it would be useful it given the smaller overhead over json and that in Rust the decoder is available and also a serde Serializer/Deserializer. However, in order to receive and decode cbor
data, it is necessary to get the raw data from Response.
Describe the solution you'd like
Add the following to Response
:
pub async fn bytes(self) -> Result<Bytes, ClientError>
{
let bytes = self.0.bytes().await?;
Ok(bytes)
}
Where Bytes
is from the bytes
crate as returned from reqwest
.
I think this would be a useful addition to the client. Would you be interested in opening a PR for it, @dodomorandi?
@dodomorandi please let me know if you are interested in opening the PR, and in case you are not, I could submit my patch instead.
I will be glad to help if I can. However, in this case I think that the work already done by @laurocaetano is more complete than my simple proposal.
I suggest @laurocaetano to open a PR with his patch, in case the introduced change are contested I can open a PR with only the bytes
method