1 | use std::pin::Pin; |
2 | use std::future::Future; |
3 | |
4 | use super::read_until_internal; |
5 | use crate::io::{self, BufRead}; |
6 | use crate::task::{Context, Poll}; |
7 | |
8 | #[doc (hidden)] |
9 | #[allow (missing_debug_implementations)] |
10 | pub struct ReadUntilFuture<'a, T: Unpin + ?Sized> { |
11 | pub(crate) reader: &'a mut T, |
12 | pub(crate) byte: u8, |
13 | pub(crate) buf: &'a mut Vec<u8>, |
14 | pub(crate) read: usize, |
15 | } |
16 | |
17 | impl<T: BufRead + Unpin + ?Sized> Future for ReadUntilFuture<'_, T> { |
18 | type Output = io::Result<usize>; |
19 | |
20 | fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { |
21 | let Self { |
22 | reader: &mut &mut T, |
23 | byte: &mut u8, |
24 | buf: &mut &mut Vec, |
25 | read: &mut usize, |
26 | } = &mut *self; |
27 | read_until_internal(reader:Pin::new(pointer:reader), cx, *byte, buf, read) |
28 | } |
29 | } |
30 | |