Skip to content

Commit a4a0e05

Browse files
committed
Add AsyncSeekExt::stream_position
1 parent 698e09a commit a4a0e05

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

futures-util/src/io/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,17 @@ pub trait AsyncSeekExt: AsyncSeek {
601601
{
602602
assert_future::<Result<u64>, _>(Seek::new(self, pos))
603603
}
604+
605+
/// Creates a future which will return the current seek position from the
606+
/// start of the stream.
607+
///
608+
/// This is equivalent to `self.seek(SeekFrom::Current(0))`.
609+
fn stream_position(&mut self) -> Seek<'_, Self>
610+
where
611+
Self: Unpin,
612+
{
613+
self.seek(SeekFrom::Current(0))
614+
}
604615
}
605616

606617
impl<S: AsyncSeek + ?Sized> AsyncSeekExt for S {}

0 commit comments

Comments
 (0)