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