#messages #utilities #contracts #unicorn #encode #decode #component

yanked unicorn-messages

Message contracts for unicorn and utilities for handling messages

Uses old Rust 2015

0.0.1 Jun 15, 2016

#9 in #unicorn


Used in 2 crates

5KB
99 lines

unicorn-messages

Message contracts for unicorn and utilities for handling messages.


lib.rs:

Message contracts for unicorn and utilities handling messages

Example usage:

use unicorn_messages::{common, Msg, encode, decode};

// All messages need an ID. So, create one first.
let id = common::ID {
    uuid: "_test".to_string(),
    component: common::Components::Core,
};

// Create a Heartbeat message
let heartbeat = Msg::Heartbeat { id: id, count: 1 };

// Encode the message to JSON bytes
let jbytes = encode(&heartbeat).unwrap();

// Decode the JSON bytes to original message
let jmsg = decode(&jbytes).unwrap();

Dependencies

~225KB