testwriter 0.1.3

A simple library and tool to generate a function that seeks to reproduce a received dbus signal message. This may be useful in writing unit tests in a TDD workflow.
Documentation
use std::time::Duration;

use dbus::blocking::Connection;
use dbus::Message;
use dbus::message::MatchRule;

// This programs implements the equivalent of running the "dbus-monitor" tool
fn main() {
    // First open up a connection to the session bus.
    let conn = Connection::new_session().expect("D-Bus connection failed");

    let rule = MatchRule::new();

    conn.add_match(rule, |_: (), _, msg| {
        handle_message(&msg);
        true
    }).expect("add_match failed");

    loop {
        conn.process(Duration::from_millis(1000)).unwrap();
    };
}

fn handle_message(msg: &Message) {
    println!("{}", testwriter::write_test(msg));
}