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