| 1 | use std::pin::Pin; |
| 2 | use std::future::Future; |
| 3 | |
| 4 | use crate::io::{self, Seek, SeekFrom}; |
| 5 | use crate::task::{Context, Poll}; |
| 6 | |
| 7 | #[doc (hidden)] |
| 8 | #[allow (missing_debug_implementations)] |
| 9 | pub struct SeekFuture<'a, T: Unpin + ?Sized> { |
| 10 | pub(crate) seeker: &'a mut T, |
| 11 | pub(crate) pos: SeekFrom, |
| 12 | } |
| 13 | |
| 14 | impl<T: Seek + Unpin + ?Sized> Future for SeekFuture<'_, T> { |
| 15 | type Output = io::Result<u64>; |
| 16 | |
| 17 | fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { |
| 18 | let pos: SeekFrom = self.pos; |
| 19 | Pin::new(&mut *self.seeker).poll_seek(cx, pos) |
| 20 | } |
| 21 | } |
| 22 | |