Crate tropocol

Source
Expand description

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();
};

Re-exports§

pub use async_net;

Modules§

async_fifo
Session Handles by async-fifo
raw
Underlying Session Task

Enums§

Error

Traits§

GetOutgoing
Object which produces outgoing messages
HandleIncoming
Object which handles incoming messages
Incoming
Trait for incoming objects
Outgoing
Trait for outgoing objects
SendFut
Alias trait for Send futures