diff options
author | Zahari Dichev <zaharidichev@gmail.com> | 2020-09-05 21:32:20 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-05 20:32:20 +0200 |
commit | 048174012d0cd8b0d763175ec2f1556e0d6fea95 (patch) | |
tree | e39bee9946a59f5ccfffc34a97199c38003bfb20 /tokio/src/fs | |
parent | 38cab933301b60a7fa730bb999bc08cdb5529476 (diff) |
fs: remove File::seek (#2810)
Fixes: #1993
Signed-off-by: Zahari Dichev <zaharidichev@gmail.com>
Diffstat (limited to 'tokio/src/fs')
-rw-r--r-- | tokio/src/fs/file.rs | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/tokio/src/fs/file.rs b/tokio/src/fs/file.rs index b801ba99..319c2c7f 100644 --- a/tokio/src/fs/file.rs +++ b/tokio/src/fs/file.rs @@ -202,68 +202,6 @@ impl File { } } - /// Seeks to an offset, in bytes, in a stream. - /// - /// # Examples - /// - /// ```no_run - /// use tokio::fs::File; - /// use tokio::prelude::*; - /// - /// use std::io::SeekFrom; - /// - /// # async fn dox() -> std::io::Result<()> { - /// let mut file = File::open("foo.txt").await?; - /// file.seek(SeekFrom::Start(6)).await?; - /// - /// let mut contents = vec![0u8; 10]; - /// file.read_exact(&mut contents).await?; - /// # Ok(()) - /// # } - /// ``` - /// - /// The [`read_exact`] method is defined on the [`AsyncReadExt`] trait. - /// - /// [`read_exact`]: fn@crate::io::AsyncReadExt::read_exact - /// [`AsyncReadExt`]: trait@crate::io::AsyncReadExt - pub async fn seek(&mut self, mut pos: SeekFrom) -> io::Result<u64> { - self.complete_inflight().await; - - let mut buf = match self.state { - Idle(ref mut buf_cell) => buf_cell.take().unwrap(), - _ => unreachable!(), - }; - - // Factor in any unread data from the buf - if !buf.is_empty() { - let n = buf.discard_read(); - - if let SeekFrom::Current(ref mut offset) = pos { - *offset += n; - } - } - - let std = self.std.clone(); - - // Start the operation - self.state = Busy(sys::run(move || { - let res = (&*std).seek(pos); - (Operation::Seek(res), buf) - })); - - let (op, buf) = match self.state { - Idle(_) => unreachable!(), - Busy(ref mut rx) => rx.await.unwrap(), - }; - - self.state = Idle(Some(buf)); - - match op { - Operation::Seek(res) => res, - _ => unreachable!(), - } - } - /// Attempts to sync all OS-internal metadata to disk. /// /// This function will attempt to ensure that all in-core data reaches the |