tokio-fs: add tokio_fs::File::seek (#434)

This commit is contained in:
Laurențiu Nicola
2018-06-21 09:43:35 -07:00
committed by Carl Lerche
parent 5753553ba3
commit ecfe2f6a05
3 changed files with 86 additions and 1 deletions
+12
View File
@@ -6,11 +6,13 @@ mod create;
mod metadata;
mod open;
mod open_options;
mod seek;
pub use self::create::CreateFuture;
pub use self::metadata::MetadataFuture;
pub use self::open::OpenFuture;
pub use self::open_options::OpenOptions;
pub use self::seek::SeekFuture;
use tokio_io::{AsyncRead, AsyncWrite};
@@ -100,6 +102,16 @@ impl File {
::blocking_io(|| self.std().seek(pos))
}
/// Seek to an offset, in bytes, in a stream.
///
/// Similar to `poll_seek`, but returning a `Future`.
///
/// This method consumes the `File` and returns it back when the future
/// completes.
pub fn seek(self, pos: io::SeekFrom) -> SeekFuture {
SeekFuture::new(self, pos)
}
/// Attempts to sync all OS-internal metadata to disk.
///
/// This function will attempt to ensure that all in-core data reaches the