pub struct WampError {
pub event: WampErrorEvent,
pub request_id: u64,
pub details: Value,
pub error: String,
pub args: Value,
pub kwargs: Value,
}
Expand description
Error
Represents an Error message in WAMP protocol.
Wamp Docs
Examples
use wamp_core::messages::{WampError, WampErrorEvent};
use serde_json::{json, from_value};
let error = WampError{
event: WampErrorEvent::Call,
request_id: 1,
details: json!({}),
error: "com.myapp.error.object_write_protected".to_string(),
args: json!(["Object is write protected."]),
kwargs: json!({"severity": 3})
};
Serializer
Implementation of Serializer for WAMP Error
use wamp_core::messages::{WampError, WampErrorEvent};
use serde_json::{json, to_string};
let error = WampError{
event: WampErrorEvent::Call,
request_id: 7814135,
details: json!({}),
error: "com.myapp.error.object_write_protected".to_string(),
args: json!(["Object is write protected."]),
kwargs: json!({"severity": 3})
};
let data = r#"[8,48,7814135,{},"com.myapp.error.object_write_protected",["Object is write protected."],{"severity":3}]"#;
let data2 = to_string(&error).unwrap();
assert_eq!(data, data2)
Deserializer
Implementation of serde Deserialize for WAMP Error
use wamp_core::messages::{WampError, WampErrorEvent};
use serde_json::{json, from_str};
let error = WampError {
event: WampErrorEvent::Call,
request_id: 7814135,
details: json!({}),
error: "com.myapp.error.object_write_protected".to_string(),
args: json!(["Object is write protected."]),
kwargs: json!({"severity": 3})
};
let data = r#"[8,48,7814135,{},"com.myapp.error.object_write_protected",["Object is write protected."],{"severity":3}]"#;
let error2 = from_str::<WampError>(data).unwrap();
assert_eq!(error, error2);
Fields§
§event: WampErrorEvent
§request_id: u64
§details: Value
§error: String
§args: Value
§kwargs: Value
Trait Implementations§
source§impl<'de> Deserialize<'de> for WampError
impl<'de> Deserialize<'de> for WampError
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 WampError
impl PartialEq for WampError
source§impl WampMessage for WampError
impl WampMessage for WampError
impl Eq for WampError
impl StructuralEq for WampError
impl StructuralPartialEq for WampError
Auto Trait Implementations§
impl RefUnwindSafe for WampError
impl Send for WampError
impl Sync for WampError
impl Unpin for WampError
impl UnwindSafe for WampError
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