Skip to content

Commit

Permalink
Add AsyncSeekExt::stream_position
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Mar 26, 2021
1 parent dddfc35 commit 9c5f4ba
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions futures-util/src/io/mod.rs
Expand Up @@ -601,6 +601,17 @@ pub trait AsyncSeekExt: AsyncSeek {
{
assert_future::<Result<u64>, _>(Seek::new(self, pos))
}

/// Creates a future which will returns 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<S: AsyncSeek + ?Sized> AsyncSeekExt for S {}
Expand Down

0 comments on commit 9c5f4ba

Please sign in to comment.