Macro interrupt

Source
macro_rules! interrupt {
    ($request_id:expr) => { ... };
    ($request_id:expr, $options:expr) => { ... };
}
Expand description

§Interrupt Macro - wamp-proto

Macro that allows for default empty implementation of options object on Cabcel.

§Examples

use wamp_core::messages::{self, Interrupt};
use wamp_core::interrupt;
use serde_json::json;

// Construct with default empty options object
let request_id = 1;
let mut interrupt_message = interrupt!(request_id);
assert_eq!(interrupt_message.options, json!({}));

// Construct with custom options
let interrupt_message2 = interrupt!(1, json!({
    "key": "value"
}));

assert_ne!(interrupt_message, interrupt_message2);
interrupt_message.options = json!({ "key": "value" });
assert_eq!(interrupt_message, interrupt_message2);

// These macro invocations are the same as the following:
let interrupt_message3 = Interrupt {
    request_id: 1,
    options: json!({
        "key": "value"
    })
};

assert_eq!(interrupt_message, interrupt_message3);
assert_eq!(interrupt_message2, interrupt_message3);