Macro authenticate

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

§Authenticate Macro - wamp-proto

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

§Examples

use wamp_core::messages::{self, Authenticate};
use wamp_core::authenticate;
use serde_json::json;

// Construct with default empty details object
let mut auth_message = authenticate!("signature");
assert_eq!(auth_message.details, json!({}));

// Construct with custom details
let auth_message2 = authenticate!("signature", json!({
    "key": "value"
}));

assert_ne!(auth_message, auth_message2);
auth_message.details = json!({ "key": "value" });
assert_eq!(auth_message, auth_message2);

// These macro invocations are the same as the following:
let auth_message3 = Authenticate {
    signature: "signature".to_string(),
    details: json!({
        "key": "value"
    })
};

assert_eq!(auth_message, auth_message3);
assert_eq!(auth_message2, auth_message3);