diff --git a/src/tostream.rs b/src/tostream.rs index 2d52c3f..34b0830 100644 --- a/src/tostream.rs +++ b/src/tostream.rs @@ -6,11 +6,20 @@ use std::io::Error; struct ToStream(T); +impl ToStream { + fn get_field(self: Pin<&mut Self>) -> Pin<&mut T> { + unsafe { self.map_unchecked_mut(|s| &mut s.0) } + } +} + +impl Unpin for ToStream{} + impl Stream for ToStream{ type Item = Result; fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { let mut buff: [u8; 1024] = [0; 1024]; - self.0.poll_read(cx, &mut buff[..]).map_ok(|l| {Bytes::copy_from_slice(&buff[0..l])}) // il manque Option + let mut t = self.get_field(); + t.poll_read(cx, &mut buff[..]).map_ok(|l| {Bytes::copy_from_slice(&buff[0..l])}).map(|res| Some(res)) } } \ No newline at end of file