Simple async codec for rkyv. Reuses streaming buffer for maximum speed!
This crate provides a makeshift adaptor for streaming &Archived<Object>
s from an AsyncRead
using a reusable external buffer, as well as a futures::Sink
implementation to serialize Object
s to an AsyncWrite
.
It uses multiformat's unsigned_varint for variable-length length encoding by default, but allows for other kinds of length encoding through the LengthEncoding
trait.
This crate has two examples: chatclient & chatserver. Run both of them at the same time to see a proof-of-concept Archive tcp stream in action.
To run:
cargo run --example chat_client
cargo run --example chat_server
Simple usage example: ```rust
struct Test {
int: u8,
string: String,
option: Option
These are a set of benchmarks, each benchmark represents 50 test objects being either sent or received.
test tests::bench_archive_sink_50 ... bench: 10,388 ns/iter (+/- 1,603)
test tests::bench_archive_sink_prearchived_50 ... bench: 2,032 ns/iter (+/- 302)
test tests::bench_archive_stream_50 ... bench: 3,544 ns/iter (+/- 438)
test tests::bench_futures_cbor_sink_50 ... bench: 14,105 ns/iter (+/- 1,160)
test tests::bench_futures_cbor_stream_50 ... bench: 9,632 ns/iter (+/- 1,437)
test tests::bench_rkyv_futures_codec_sink_50 ... bench: 6,671 ns/iter (+/- 521)
test tests::bench_rkyv_futures_codec_stream_50 ... bench: 4,925 ns/iter (+/- 948)
test tests::bench_rkyv_writer_50 ... bench: 3,547 ns/iter (+/- 271)
test tests::bench_u64_length_encoding ... bench: 4,226 ns/iter (+/- 327)
test tests::bench_varint_length_encoding ... bench: 4,243 ns/iter (+/- 343)
The fastest real benchmark (full serialization and bytecheck) is using RkyvWriter
for writing and archive_stream
for reading.
This is compared to the slowest benchmark: futures_codec library's CborCodec
.
Feel free to contribute your own benchmarks!