macro_rules! challenge {
($authmethod:expr) => { ... };
($authmethod:expr, $details:expr) => { ... };
}
Expand description
§Challenge Macro - wamp-proto
Macro that allows for default empty implementation of details object on Challenge.
§Examples
use wamp_core::messages::{self, Challenge};
use wamp_core::challenge;
use serde_json::json;
// Construct with default empty details object
let mut challenge_message = challenge!("authmethod");
assert_eq!(challenge_message.details, json!({}));
// Construct with custom details
let challenge_message2 = challenge!("authmethod", json!({
"key": "value"
}));
assert_ne!(challenge_message, challenge_message2);
challenge_message.details = json!({ "key": "value" });
assert_eq!(challenge_message, challenge_message2);
// These macro invocations are the same as the following:
let challenge_message3 = Challenge {
authmethod: "authmethod".to_string(),
details: json!({
"key": "value"
})
};
assert_eq!(challenge_message, challenge_message3);
assert_eq!(challenge_message2, challenge_message3);