Module slimproto::framed

source ·
Expand description

These are the structs that you instantiate in your application.

In order to used framed packets you can use:

  • FramedRead to just decode packets into your own message type
  • FramedWrite if you just want to send encoded messages
  • Framed to do both

The Framed* structs take ownership the underlying Read or Write object. This means that they will work in multi-threaded applications but this presents a problem in the very likely case when the Read and Write object is the same TcpStream. In this case use the try_clone method on the stream to get a thread-safe handle.

A Framed type is useful in single-threaded applications where you just want a single object to encode and decode. For multi-threaded applications you can use FramedRead in one thread and FramedWrite in another.

Structs

Traits