Closed incker closed 7 months ago
You need to use async_compression::tokio::bufread::GzipDecoder
The one in the tokio module provides types that implements tokio io traits.
P.S. you need to enable feature tokio of async-compression
Can you help?
I have added tokio feature
I have replaced to use async_compression::tokio::bufread::GzipDecoder;
in my example, But I received more compilation errors
At least this one:
--> dashd/miner-dash-daemon/src/my_test.rs:17:36
|
17 | let decoder = GzipDecoder::new(BufReader::new(reader));
| ---------------- ^^^^^^^^^^^^^^^^^^^^^^ the trait `tokio::io::AsyncBufRead` is not implemented for `futures::io::BufReader<IntoAsyncRead<futures::stream::MapErr<impl Stream<Item = Result<bytes::Bytes, reqwest::Error>>, {closure@dashd/miner-dash-daemon/src/my_test.rs:15:18: 15:21}>>>`
| |
| required by a bound introduced by this call
Is BufReader
from tokio?
Ufff. It was not easy, but it works now. Thank you !!!
use std::error;
use std::io;
use futures::TryStreamExt;
use tokio::io::AsyncRead;
use tokio_util::io::StreamReader;
async fn main() -> Result<(), Box<dyn error::Error>> {
let response = reqwest::get("http://localhost:8000/test.txt.gz").await?;
let reader = response
.bytes_stream()
.map_err(|err| io::Error::new(io::ErrorKind::InvalidData, err));
let decoder = async_compression::tokio::bufread::GzipDecoder::new(StreamReader::new(reader));
some_func(decoder);
Ok(())
}
pub fn some_func<St: AsyncRead>(_: St) {}
Hello,
Here is an example.
And error is
Maybe i do not understand something. hep please)