#async-io #frame #framed #io #async #net #io-operations

framed_aio

A crate which allows performing async io operations in a framed manner

2 releases

0.1.1 Sep 13, 2022
0.1.0 Sep 13, 2022

#976 in Asynchronous

44 downloads per month

GPL-3.0-only

27KB
330 lines

A crate for framed async io.

This crate allows performing io operations in a framed manner, which means that instead of sending and receiving bytes from a stream of bytes, you can send and receive frames of bytes.

The reading of frames is implemented in a cancel safe way, which means that you can use it in one of the branches of tokio::select!.

The implementation is also tuned for high performance and low overhead.

Goals

  • Provide cancel safety
  • High performance
  • Low overhead

Examples

For examples of using this crate, check out the examples directory.


lib.rs:

A crate for framed async io.

This crate allows performing io operations in a framed manner, which means that instead of sending and receiving bytes from a stream of bytes, you can send and receive frames of bytes.

The reading of frames is implemented in a cancel safe way, which means that you can use it in one of the branches of tokio::select!.

The implementation is also tuned for high performance and low overhead.

Goals

  • Provide cancel safety
  • High performance
  • Low overhead

Usage

To read from some type which implements AsyncRead in a framed manner, you can wrap it in a FramedReader and call FramedReader::read_frame.

To write to some type which implements AsyncWrite in a framed manner, you can wrap it in a FramedWriter and call FramedWriter::write_frame or FramedWriter::write_frame_cancel_safe for writing a frame in a cancel safe way.

Typed Frames

If you wish to send typed frames, which is frames that contains serialized objects, you need to opt in the typed feature flag.

You can then use the FramedReader::read_frame_typed and FramedWriter::write_frame_typed functions to read and write typed frames.

Dependencies

~2.4–4MB
~69K SLoC