pub struct Subscribe {
pub request_id: u64,
pub options: Value,
pub topic: String,
}
Expand description
Subscribe - wamp-proto
Represents an unsubscribe frame in the WAMP protocol.
Examples
use wamp_core::messages::Subscribe;
use wamp_core::subscribe;
use serde_json::json;
let subscribed = Subscribe {
request_id: 1,
topic: "topic".to_string(),
options: json!({})
};
Serializer
Implements serde Serialize trait for Subscribe
use wamp_core::messages::Subscribe;
use serde_json::{json, to_string};
use wamp_core::subscribe;
let data = r#"[32,1,{},"com.myapp.mytopic1"]"#;
let subscribe1 = subscribe!("com.myapp.mytopic1");
let subscribe = Subscribe {
request_id: 1,
topic: "com.myapp.mytopic1".to_string(),
options: json!({})
};
let data2 = to_string(&subscribe1).unwrap();
let data3 = to_string(&subscribe).unwrap();
assert_eq!(data, data2);
assert_eq!(data2, data3);
Deserializer
Implements serde Deserialize trait for Subscribe
use wamp_core::messages::Subscribe;
use serde_json::from_str;
use wamp_core::subscribe;
let data = r#"[32,1,{},"com.myapp.mytopic1"]"#;
let subscribe = from_str::<Subscribe>(data).unwrap();
let subscribe2 = subscribe!("com.myapp.mytopic1");
assert_eq!(subscribe, subscribe2);
Fields§
§request_id: u64
§options: Value
§topic: String
Trait Implementations§
source§impl<'de> Deserialize<'de> for Subscribe
impl<'de> Deserialize<'de> for Subscribe
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 Subscribe
impl PartialEq for Subscribe
source§impl WampMessage for Subscribe
impl WampMessage for Subscribe
impl Eq for Subscribe
impl StructuralEq for Subscribe
impl StructuralPartialEq for Subscribe
Auto Trait Implementations§
impl RefUnwindSafe for Subscribe
impl Send for Subscribe
impl Sync for Subscribe
impl Unpin for Subscribe
impl UnwindSafe for Subscribe
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