From de8bd2fb52a9a75312ec6de675f3961ff65ec4c1 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Sat, 27 Mar 2021 01:04:23 +0900 Subject: [PATCH] Add AsyncSeekExt::stream_position --- futures-util/src/io/mod.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/futures-util/src/io/mod.rs b/futures-util/src/io/mod.rs index 1437930f66..437aedf0c4 100644 --- a/futures-util/src/io/mod.rs +++ b/futures-util/src/io/mod.rs @@ -601,6 +601,17 @@ pub trait AsyncSeekExt: AsyncSeek { { assert_future::, _>(Seek::new(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)) + } } impl AsyncSeekExt for S {}