AL
Size: a a a
AL
M
A
YJ
AL
a
KB
a
KB
a
KB
KB
AC
rust
use futures::Stream;
use tokio::io::{AsyncRead, ReadBuf};
struct Reader<T> {
source: T,
buffer: Vec<u8>,
}
impl<T: AsyncRead> Stream for Reader<T> {
type Item = ();
fn poll_next(
self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
self.source
.poll_read(cx, &mut ReadBuf::new(self.buffer.as_mut_slice()))
.map(|result| result.ok())
}
}
oghttps://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=cadc85469d3b59e1a7eb77ad7e886a02
no method named `poll_read` found for type parameter `T` in the current scope
AV
Ext
трейт не забыл?AV
AsyncReadExt
, напримерMB
rust
use futures::Stream;
use tokio::io::{AsyncRead, ReadBuf};
struct Reader<T> {
source: T,
buffer: Vec<u8>,
}
impl<T: AsyncRead> Stream for Reader<T> {
type Item = ();
fn poll_next(
self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
self.source
.poll_read(cx, &mut ReadBuf::new(self.buffer.as_mut_slice()))
.map(|result| result.ok())
}
}
oghttps://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=cadc85469d3b59e1a7eb77ad7e886a02
no method named `poll_read` found for type parameter `T` in the current scope
AC
Ext
трейт не забыл?AC
MB
AC