使用旧的Rust 2015
0.0.1 |
|
---|
#9 in #unicorn
用于 2 crates
5KB
99 代码行数
unicorn-messages
用于unicorn的消息合约和消息处理的实用工具。
lib.rs
:
用于unicorn和消息处理的实用工具的消息合约
示例用法
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();
依赖关系
~225KB