pub struct Publish {
pub request_id: u64,
pub options: Value,
pub topic: String,
pub args: Value,
pub kwargs: Value,
}
Expand description
Publish - wamp-proto
Represents an publish message in the WAMP protocol.
Examples
use wamp_core::messages::Publish;
use wamp_core::publish;
use serde_json::{json, Value};
let publish = Publish {
request_id: 1,
options: json!({ }),
topic: "topic".to_string(),
args: Value::Null,
kwargs: Value::Null
};
let publish2 = publish!("topic");
assert_eq!(publish, publish2);
Serializer
Serde Serialize trait implementation for publish.
use wamp_core::messages::Publish;
use serde_json::{json, to_string};
let publish = Publish {
request_id: 7814135,
options: json!({}),
topic: "com.myapp.user.new".to_string(),
args: json!(["johnny"]),
kwargs: json!({"firstname":"John","surname":"Doe"})
};
let publish2_string = r#"[16,7814135,{},"com.myapp.user.new",["johnny"],{"firstname":"John","surname":"Doe"}]"#;
let publish_string = to_string(&publish).unwrap();
assert_eq!(publish_string, publish2_string);
Deserializer
Serde Deserialize trait implementation for publish.
use wamp_core::messages::Publish;
use serde_json::{json, from_str};
let publish = Publish {
request_id: 7814135,
options: json!({}),
topic: "com.myapp.user.new".to_string(),
args: json!(["johnny"]),
kwargs: json!({"firstname":"John","surname":"Doe"})
};
let publish2_string = r#"[16,7814135,{},"com.myapp.user.new",["johnny"],{"firstname":"John","surname":"Doe"}]"#;
let publish2 = from_str::<Publish>(publish2_string).unwrap();
assert_eq!(publish, publish2);
Fields§
§request_id: u64
§options: Value
§topic: String
§args: Value
§kwargs: Value
Trait Implementations§
source§impl<'de> Deserialize<'de> for Publish
impl<'de> Deserialize<'de> for Publish
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 Publish
impl PartialEq for Publish
source§impl WampMessage for Publish
impl WampMessage for Publish
impl Eq for Publish
impl StructuralEq for Publish
impl StructuralPartialEq for Publish
Auto Trait Implementations§
impl RefUnwindSafe for Publish
impl Send for Publish
impl Sync for Publish
impl Unpin for Publish
impl UnwindSafe for Publish
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