The framed-msgpack project is a Rust crate, a.k.a. library, that provides a codec for use with the tokio-rs project. MessagePack-based messages, or payloads, are sent and received with the total message length prefixed as a 32-bit unsigned integer encoded in four (4) Big-Endian bytes. The implementation is largely based on the length delimited codec provided in the tokio-io module but instead of decoding and encoding a payload from a stream and sink into a byte buffer, a payload is decoded and encoded as MessagePack messages without the prefix length bytes, respectively.
First, add this to your Cargo.toml
:
[dependencies]
framed-msgpack = { git = "https://github.com/volks73/framed-msgpack.git" }
Next, add this to your crate:
extern crate framed_msgpack;
Clone this repository, then run the following command:
$ cargo run --example echo_server
This will run a server at localhost:12345
. From another terminal, connect to the server and send framed-msgpack messages. The binary messages will be returned unchanged. A combination of the netcat, nc
, application on UNIX-like systems, or ncat for Windows, and the panser application can be used to create framed-msgpack messages to send to the example echo server. For example,
$ echo '[0,1,2]' | panser --from json --to json --sized-output | nc localhost 12345 | panser --from msgpack --to json --sized-input --delimited-output 0Ah
[0,1,2]
$
See the LICENSE file for more information about licensing and copyright.