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