How can I get a `tokio::io::BufReader` from `bytes::Bytes`

I get the bytes::Bytes from reqwest::Response in each future. I know there is a method reader, but can I leverage the tokio::io::BufReader to work with Bytes ?

i'm trying to use tokio-io-uring 0.2.0 to this in async way,

they says that is a feature of tokio-io-uring to obtain a IObuf and IObuf mut from bytes, perhaps this is going to the way of solution (sorry but today i can't test it, and yesterday it gave me to my code problems of iobuf and bytes not implemented)

thanks. will try it

Do you need an actual BufReader (the struct), or just an AsyncBufRead (the trait)?

a BufReader I guess

You can put the Bytes object in a Cursor. That type will implement AsyncRead, so you can put it inside an BufReader. (But I don't understand why you need this.)

Because I'm trying to use tokio::io::copy, and I want to wrap these Bytes into something that implement AsyncRead, maybe a BufReader?

To write a Bytes to something, just use write_all.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.