1use super::File;
2
3use futures::{Future, Poll};
4
5use std::io;
6
7#[derive(Debug)]
9pub struct SeekFuture {
10 inner: Option<File>,
11 pos: io::SeekFrom,
12}
13
14impl SeekFuture {
15 pub(crate) fn new(file: File, pos: io::SeekFrom) -> Self {
16 Self {
17 pos,
18 inner: Some(file),
19 }
20 }
21}
22
23impl Future for SeekFuture {
24 type Item = (File, u64);
25 type Error = io::Error;
26
27 fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
28 let pos = try_ready!(self
29 .inner
30 .as_mut()
31 .expect("Cannot poll `SeekFuture` after it resolves")
32 .poll_seek(self.pos));
33 let inner = self.inner.take().unwrap();
34 Ok((inner, pos).into())
35 }
36}