Struct wamp_core::messages::authenticate::Authenticate
source · pub struct Authenticate {
pub signature: String,
pub details: Value,
}
Expand description
Authenticate - wamp-proto
Represents an Authentication message in the WAMP protocol.
Examples
use wamp_core::messages::Authenticate;
use wamp_core::authenticate;
use serde_json::json;
let auth_message = Authenticate {
signature: "signature".to_string(),
details: json!({})
};
Serializer
Implements serde Serialize trait for Authenticate
use wamp_core::messages::Authenticate;
use serde_json::{json, to_string};
// Create an Authenticate message
let auth = Authenticate {
signature: "signature".to_string(),
details: json!({ "key": "value" })
};
// Establish raw json data string
let data = r#"[5,"signature",{"key":"value"}]"#;
// Here we convert it from an `Authenticate` frame, to a string representation.
let auth = to_string(&auth).unwrap();
// Confirm that our auth frame strings are equal to each other
assert_eq!(auth, data);
Deserializer
Implements serde Deserialize trait for Authenticate
use wamp_core::messages::Authenticate;
use serde_json::from_str;
// Here is our raw json data string
let data = r#"[5,"signature",{}]"#;
// Here we convert it to an `Authenticate` frame
let auth = from_str::<Authenticate>(data).unwrap();
// Confirm that our signature and details deserialized
assert_eq!(auth.signature, "signature");
assert_eq!(auth.details, serde_json::json!({}));
Fields§
§signature: String
§details: Value
Trait Implementations§
source§impl Clone for Authenticate
impl Clone for Authenticate
source§fn clone(&self) -> Authenticate
fn clone(&self) -> Authenticate
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for Authenticate
impl Debug for Authenticate
source§impl<'de> Deserialize<'de> for Authenticate
impl<'de> Deserialize<'de> for Authenticate
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl From<Authenticate> for Messages
impl From<Authenticate> for Messages
source§fn from(v: Authenticate) -> Messages
fn from(v: Authenticate) -> Messages
Converts to this type from the input type.
source§impl From<Messages> for Authenticate
impl From<Messages> for Authenticate
source§fn from(v: Messages) -> Authenticate
fn from(v: Messages) -> Authenticate
Converts to this type from the input type.
source§impl PartialEq for Authenticate
impl PartialEq for Authenticate
source§fn eq(&self, other: &Authenticate) -> bool
fn eq(&self, other: &Authenticate) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl Serialize for Authenticate
impl Serialize for Authenticate
source§impl TryFrom<Authenticate> for Message
impl TryFrom<Authenticate> for Message
source§impl WampMessage for Authenticate
impl WampMessage for Authenticate
impl Eq for Authenticate
impl StructuralEq for Authenticate
impl StructuralPartialEq for Authenticate
Auto Trait Implementations§
impl RefUnwindSafe for Authenticate
impl Send for Authenticate
impl Sync for Authenticate
impl Unpin for Authenticate
impl UnwindSafe for Authenticate
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more