Trait smol::io::AsyncSeekExt
source · [−]pub trait AsyncSeekExt: AsyncSeek {
fn seek(&mut self, pos: SeekFrom) -> SeekFuture<'_, Self>ⓘNotable traits for SeekFuture<'_, S>impl<'_, S> Future for SeekFuture<'_, S> where
S: AsyncSeek + Unpin + ?Sized, type Output = Result<u64, Error>;
where
Self: Unpin,
{ ... }
}
Expand description
Extension trait for AsyncSeek
.
Provided methods
fn seek(&mut self, pos: SeekFrom) -> SeekFuture<'_, Self>ⓘNotable traits for SeekFuture<'_, S>impl<'_, S> Future for SeekFuture<'_, S> where
S: AsyncSeek + Unpin + ?Sized, type Output = Result<u64, Error>;
where
Self: Unpin,
fn seek(&mut self, pos: SeekFrom) -> SeekFuture<'_, Self>ⓘNotable traits for SeekFuture<'_, S>impl<'_, S> Future for SeekFuture<'_, S> where
S: AsyncSeek + Unpin + ?Sized, type Output = Result<u64, Error>;
where
Self: Unpin,
S: AsyncSeek + Unpin + ?Sized, type Output = Result<u64, Error>;
Seeks to a new position in a byte stream.
Returns the new position in the byte stream.
A seek beyond the end of stream is allowed, but behavior is defined by the implementation.
Examples
use futures_lite::io::{AsyncSeekExt, Cursor, SeekFrom};
let mut cursor = Cursor::new("hello");
// Move the cursor to the end.
cursor.seek(SeekFrom::End(0)).await?;
// Check the current position.
assert_eq!(cursor.seek(SeekFrom::Current(0)).await?, 5);