From a257a3a2b12e479c8d895d0f6fb5eb0e48898edd Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Sat, 27 Mar 2021 12:28:51 +0900 Subject: [PATCH] io: add AsyncSeekExt::stream_position (#3650) --- tokio/src/io/util/async_seek_ext.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tokio/src/io/util/async_seek_ext.rs b/tokio/src/io/util/async_seek_ext.rs index 813913fdc..297a4a61a 100644 --- a/tokio/src/io/util/async_seek_ext.rs +++ b/tokio/src/io/util/async_seek_ext.rs @@ -66,6 +66,17 @@ cfg_io_util! { { seek(self, pos) } + + /// Creates a future which will return the current seek position from the + /// start of the stream. + /// + /// This is equivalent to `self.seek(SeekFrom::Current(0))`. + fn stream_position(&mut self) -> Seek<'_, Self> + where + Self: Unpin, + { + self.seek(SeekFrom::Current(0)) + } } }