Module prelude

Module prelude 

Source
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, StreamExt for 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 operations

Traits Future, Stream, AsyncRead, AsyncWrite, AsyncBufRead, AsyncSeek, and their extensions.

§Examples

use futures_lite::prelude::*;

Traits§

AsyncBufRead
Read bytes asynchronously.
AsyncRead
Read bytes asynchronously.
AsyncSeek
Seek bytes asynchronously.
AsyncWrite
Write bytes asynchronously.
Future
A future represents an asynchronous computation, commonly obtained by use of async.
Stream
A stream of values produced asynchronously.
_
Extension trait for Future.
_
Extension trait for Stream.
_
Extension trait for AsyncBufRead.
_
Extension trait for AsyncRead.
_
Extension trait for AsyncSeek.
_
Extension trait for AsyncWrite.