nats-types
The nats-types
crate contains an enum ProtocolMessage
. This enum can be used to
parse the string output from a NATS server as well as produce strings to be sent to
a NATS server.
The primary use for this crate is to be used in support of building a NATS client, though other potential uses might be possible.
To produce a protocol message, simply create the enum:
extern crate nats_types;
use ;
let publish = Publish;
let out = format!;
assert_eq!;
The same message can be constructed from the 2-line message received from a NATS server:
extern crate nats_types;
use FromStr;
use ;
let msg = "PUB FOO 11\r\nHello NATS!\r\n";
let protomsg = from_str.unwrap;
if let Publish = protomsg