compio-io 0.9.0

IO traits for completion based async IO
Documentation

compio-io

MIT licensed crates.io docs.rs Check Test

IO traits for completion-based async IO.

This crate provides async IO traits designed for completion-based operations. Unlike traditional poll-based async IO traits, these traits work with owned buffers and return both the buffer and the operation result upon completion.

The crate itself is runtime-agnostic and can be used with any completion-based async IO runtime.

Usage

For application

Use compio::io re-exported from compio crate, then use the io traits in your application:

use compio::io::{AsyncRead, AsyncWrite};

For library

If you are writing libraries that want to support completion-based async IO, you can depend on this crate directly:

cargo add compio-io

Then you can use the io traits in your library:

use compio_io::{AsyncRead, AsyncWrite};

Content

Fundamental

  • AsyncRead: Async read into a buffer implements IoBufMut
  • AsyncReadAt: Async read into a buffer implements IoBufMut with offset
  • AsyncWrite: Async write from a buffer implements IoBuf
  • AsyncWriteAt: Async write from a buffer implements IoBuf with offset

Buffered IO

  • AsyncBufRead: Trait of async read with buffered content
  • BufReader: An async reader with internal buffer
  • BufWriter: An async writer with internal buffer

Extension

  • AsyncReadExt: Extension trait for AsyncRead
  • AsyncReadAtExt: Extension trait for AsyncReadAt
  • AsyncWriteExt: Extension trait for AsyncWrite
  • AsyncWriteAtExt: Extension trait for AsyncWriteAt

Adapters

  • framed::Framed: Adapts AsyncRead to Stream and AsyncWrite to Sink, with framed en/decoding.
  • compat::SyncStream: Adapts async IO to std blocking io (requires compat feature)
  • compat::AsyncStream: Adapts async IO to futures_util::io traits (requires compat feature)

Utils

See docs.rs for detail: copy, null, repeat, split, split_unsync.