#tcp #lan #protocols #serde #channel

tropocol

Send and receive serde-compatible objects over TCP (async)

3 releases

0.1.2 Apr 20, 2025
0.1.1 Apr 18, 2025
0.1.0 Apr 18, 2025

#1029 in Encoding

Download history 389/week @ 2025-04-16 28/week @ 2025-04-23

417 downloads per month

MIT license

11KB
186 lines

Send and receive serde-compatible objects over TCP (async)

With the log feature (enabled by default), the following events will be logged:

  • clean disconnects (DEBUG)
  • dirty disconnects (ERROR)
  • codec/serde errors (ERROR)
  • message reception/emission (TRACE)

Roadmap

  • async-fifo support
  • async-channel support
  • logging
  • compression (gzip, lz4, lzma)
  • other encodings (CBOR, BSON, MessagePack)

Example

let addr = ("127.0.0.1", 9000);
let stream = std::net::TcpStream::connect(addr).unwrap();
let stream = async_net::TcpStream::try_from(stream).unwrap();

type Incoming = String;
type Outgoing = u32;

let (task, tx, mut rx) = tropocol::async_fifo::session::<Outgoing, Incoming>(stream);
// spawn this task in an asynchronous executor

tx.send(0u32 as Outgoing);

async {
    let s: Incoming = rx.recv().await.unwrap();
};

Dependencies

~4–14MB
~183K SLoC