From fe1b73e307df759e58a0a6cd5eb38ebe1c297d45 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Sat, 27 Mar 2021 01:30:30 +0900 Subject: [PATCH] io: add AsyncSeekExt::stream_position --- 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 813913fdc81..297a4a61a3b 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)) + } } }