pub struct Hello {
pub realm: String,
pub details: Value,
}
Expand description
Hello - wamp-proto
Represents an Hello message in the WAMP protocol.
Examples
use wamp_core::messages::Hello;
use wamp_core::hello;
use serde_json::json;
let hello_message = Hello {
realm: "realm".to_string(),
details: json!({})
};
Serializer
use wamp_core::messages::Hello;
use serde_json::{json, to_string};
// Create an Hello message
let hello = Hello {
realm: "realm".to_string(),
details: json!({ "key": "value" })
};
// Establish raw json data string
let data = r#"[1,"realm",{"key":"value"}]"#;
// Here we convert it from an `Hello` frame, to a string representation.
let hello = to_string(&hello).unwrap();
// Confirm that our hello frame strings are equal to each other
assert_eq!(hello, data);
Deserializer
Implements serde Deserialize trait for hello
use wamp_core::messages::Hello;
use serde_json::from_str;
// Here is our raw json data string
let data = r#"[1,"realm",{}]"#;
// Here we convert it to an `Hello` frame
let hello = from_str::<Hello>(data).unwrap();
// Confirm that our realm and details deserialized
assert_eq!(hello.realm, "realm");
assert_eq!(hello.details, serde_json::json!({}));
Implements serde Serialize trait for hello
Fields§
§realm: String
§details: Value
Trait Implementations§
source§impl<'de> Deserialize<'de> for Hello
impl<'de> Deserialize<'de> for Hello
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 PartialEq for Hello
impl PartialEq for Hello
source§impl WampMessage for Hello
impl WampMessage for Hello
impl Eq for Hello
impl StructuralEq for Hello
impl StructuralPartialEq for Hello
Auto Trait Implementations§
impl RefUnwindSafe for Hello
impl Send for Hello
impl Sync for Hello
impl Unpin for Hello
impl UnwindSafe for Hello
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