1mod seek;
23use seek::SeekFuture;
45use crate::io::SeekFrom;
67pub use futures_io::AsyncSeek as Seek;
89#[doc = r#"
10 Extension methods for [`Seek`].
1112 [`Seek`]: ../trait.Seek.html
13"#]
14pub trait SeekExt: Seek {
15#[doc = r#"
16 Seeks to a new position in a byte stream.
1718 Returns the new position in the byte stream.
1920 A seek beyond the end of stream is allowed, but behavior is defined by the
21 implementation.
2223 # Examples
2425 ```no_run
26 # fn main() -> std::io::Result<()> { async_std::task::block_on(async {
27 #
28 use async_std::fs::File;
29 use async_std::io::SeekFrom;
30 use async_std::prelude::*;
3132 let mut file = File::open("a.txt").await?;
3334 let file_len = file.seek(SeekFrom::End(0)).await?;
35 #
36 # Ok(()) }) }
37 ```
38 "#]
39fn seek(
40&mut self,
41 pos: SeekFrom,
42 ) -> SeekFuture<'_, Self>
43where
44Self: Unpin,
45 {
46 SeekFuture { seeker: self, pos }
47 }
48}
4950impl<T: Seek + ?Sized> SeekExt for T {}