mqtt-protocol 0.3.0

MQTT Protocol Library
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
extern crate mqtt;

use std::io::Cursor;

use mqtt::{Encodable, Decodable};
use mqtt::packet::*;

fn main() {
    let d = DisconnectPacket::new();
    let mut buf = Vec::new();
    d.encode(&mut buf).unwrap();

    println!("Encoded: {:?}", buf);

    let mut dec_buf = Cursor::new(&buf[..]);
    let auto_decode = VariablePacket::decode(&mut dec_buf).unwrap();
    println!("Variable packet decode: {:?}", auto_decode);
}