Macro goodbye

Source
macro_rules! goodbye {
    ($reason:expr) => { ... };
    ($reason:expr, $details:expr) => { ... };
}
Expand description

§Goodbye Macro - wamp-proto

Macro that allows for default empty implementation of details object on Goodbye.

§Examples

use wamp_core::messages::Goodbye;
use wamp_core::goodbye;
use serde_json::json;

// Construct with default empty details object
let mut goodbye_message = goodbye!("wamp.close.system_shutdown");
assert_eq!(goodbye_message.details, json!({}));

// Construct with custom details
let goodbye_message2 = goodbye!("wamp.close.system_shutdown", json!({
    "message": "The host is shutting down now."
}));

assert_ne!(goodbye_message, goodbye_message2);
goodbye_message.details = json!({ "message": "The host is shutting down now." });
assert_eq!(goodbye_message, goodbye_message2);

// These macro invocations are the same as the following:
let goodbye_message3 = Goodbye {
    reason: "wamp.close.system_shutdown".to_string(),
    details: json!({
        "message": "The host is shutting down now."
    })
};

assert_eq!(goodbye_message, goodbye_message3);
assert_eq!(goodbye_message2, goodbye_message3);