pub trait AsyncSeekExt: AsyncSeek {
// Provided method
fn seek(&mut self, pos: SeekFrom) -> SeekFuture<'_, Self> ⓘ
where Self: Unpin { ... }
}Expand description
Complete async runtime utilities and traits.
This re-exports all items from futures_lite, providing:
- Async I/O traits:
AsyncRead,AsyncWrite,AsyncBufRead, etc. - Stream utilities:
Stream,StreamExtfor async iteration - Future utilities:
FutureExt,future::ready,future::pending - Async combinators:
join!,try_join!,select! - I/O utilities: Async file operations, networking, etc.
This saves you from having to import futures_lite directly and provides
all the async primitives needed for HTTP operations.
§Examples
§Stream Processing
use http_kit::utils::{stream, StreamExt};
let data = vec!["chunk1", "chunk2", "chunk3"];
let mut stream = stream::iter(data);
while let Some(chunk) = stream.next().await {
println!("Processing: {}", chunk);
}§Async I/O
use http_kit::utils::{AsyncReadExt, AsyncWriteExt};
// These traits are available for async I/O operationsExtension trait for AsyncSeek.
Provided Methods§
Sourcefn seek(&mut self, pos: SeekFrom) -> SeekFuture<'_, Self> ⓘwhere
Self: Unpin,
fn seek(&mut self, pos: SeekFrom) -> SeekFuture<'_, Self> ⓘwhere
Self: Unpin,
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);Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.