pub enum Messages {
Show 25 variants
Abort(Abort),
Authenticate(Authenticate),
Call(Call),
Cancel(Cancel),
Challenge(Challenge),
Error(WampError),
Event(Event),
Goodbye(Goodbye),
Hello(Hello),
Interrupt(Interrupt),
Invocation(Invocation),
Publish(Publish),
Published(Published),
Register(Register),
Registered(Registered),
Result(WampResult),
Subscribe(Subscribe),
Subscribed(Subscribed),
Unregister(Unregister),
Unregistered(Unregistered),
Unsubscribe(Unsubscribe),
Unsubscribed(Unsubscribed),
Welcome(Welcome),
Yield(Yield),
Extension(Vec<Value>),
}
Expand description
Messages Enum
This represents each of the messages described in the WAMP protocol.
This includes its own deserializer (you should serialize using the inner struct always).
It also implements From<*n> for Messages
where n = each WAMP message.
Examples
use wamp_core::messages::{Call, Messages};
use wamp_core::call;
use serde_json::{Value, json, from_str};
let message = Messages::from(call!("topic"));
// Which is the same as this:
let mut message2 = Messages::Call(Call {
request_id: 1,
options: json!({}),
procedure: "topic".to_string(),
args: Value::Null,
kwargs: Value::Null
});
assert_eq!(message, message2);
// Lets make a raw string to pass to the deserializer (this is a Call message)
let data = r#"[48,1,{},"topic"]"#;
// Deserialize the raw string
let message3 = from_str::<Messages>(data).unwrap();
assert_eq!(message2, message3);
Variants§
Abort(Abort)
Authenticate(Authenticate)
Call(Call)
Cancel(Cancel)
Challenge(Challenge)
Error(WampError)
Event(Event)
Goodbye(Goodbye)
Hello(Hello)
Interrupt(Interrupt)
Invocation(Invocation)
Publish(Publish)
Published(Published)
Register(Register)
Registered(Registered)
Result(WampResult)
Subscribe(Subscribe)
Subscribed(Subscribed)
Unregister(Unregister)
Unregistered(Unregistered)
Unsubscribe(Unsubscribe)
Unsubscribed(Unsubscribed)
Welcome(Welcome)
Yield(Yield)
Extension(Vec<Value>)
Implementations§
source§impl Messages
impl Messages
sourcepub fn id(&self) -> Option<u64>
pub fn id(&self) -> Option<u64>
Get Message ID
Get the message ID of a WAMP message. This uses the static u64 for any known WAMP messages.
For Extension messages, it attempts to get the ID and returns None otherwise.
Examples
use wamp_core::call;
use wamp_core::messages::Messages;
let message = Messages::from(call!("topic"));
let message_id = message.id();
assert_eq!(message_id, Some(48));
Trait Implementations§
source§impl<'de> Deserialize<'de> for Messages
impl<'de> Deserialize<'de> for Messages
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 From<Authenticate> for Messages
impl From<Authenticate> for Messages
source§fn from(v: Authenticate) -> Messages
fn from(v: Authenticate) -> Messages
Converts to this type from the input type.
source§impl From<Invocation> for Messages
impl From<Invocation> for Messages
source§fn from(v: Invocation) -> Messages
fn from(v: Invocation) -> Messages
Converts to this type from the input type.
source§impl From<Messages> for Authenticate
impl From<Messages> for Authenticate
source§fn from(v: Messages) -> Authenticate
fn from(v: Messages) -> Authenticate
Converts to this type from the input type.
source§impl From<Messages> for Invocation
impl From<Messages> for Invocation
source§fn from(v: Messages) -> Invocation
fn from(v: Messages) -> Invocation
Converts to this type from the input type.
source§impl From<Messages> for Registered
impl From<Messages> for Registered
source§fn from(v: Messages) -> Registered
fn from(v: Messages) -> Registered
Converts to this type from the input type.
source§impl From<Messages> for Subscribed
impl From<Messages> for Subscribed
source§fn from(v: Messages) -> Subscribed
fn from(v: Messages) -> Subscribed
Converts to this type from the input type.
source§impl From<Messages> for Unregister
impl From<Messages> for Unregister
source§fn from(v: Messages) -> Unregister
fn from(v: Messages) -> Unregister
Converts to this type from the input type.
source§impl From<Messages> for Unregistered
impl From<Messages> for Unregistered
source§fn from(v: Messages) -> Unregistered
fn from(v: Messages) -> Unregistered
Converts to this type from the input type.
source§impl From<Messages> for Unsubscribe
impl From<Messages> for Unsubscribe
source§fn from(v: Messages) -> Unsubscribe
fn from(v: Messages) -> Unsubscribe
Converts to this type from the input type.
source§impl From<Messages> for Unsubscribed
impl From<Messages> for Unsubscribed
source§fn from(v: Messages) -> Unsubscribed
fn from(v: Messages) -> Unsubscribed
Converts to this type from the input type.
source§impl From<Registered> for Messages
impl From<Registered> for Messages
source§fn from(v: Registered) -> Messages
fn from(v: Registered) -> Messages
Converts to this type from the input type.
source§impl From<Subscribed> for Messages
impl From<Subscribed> for Messages
source§fn from(v: Subscribed) -> Messages
fn from(v: Subscribed) -> Messages
Converts to this type from the input type.
source§impl From<Unregister> for Messages
impl From<Unregister> for Messages
source§fn from(v: Unregister) -> Messages
fn from(v: Unregister) -> Messages
Converts to this type from the input type.
source§impl From<Unregistered> for Messages
impl From<Unregistered> for Messages
source§fn from(v: Unregistered) -> Messages
fn from(v: Unregistered) -> Messages
Converts to this type from the input type.
source§impl From<Unsubscribe> for Messages
impl From<Unsubscribe> for Messages
source§fn from(v: Unsubscribe) -> Messages
fn from(v: Unsubscribe) -> Messages
Converts to this type from the input type.
source§impl From<Unsubscribed> for Messages
impl From<Unsubscribed> for Messages
source§fn from(v: Unsubscribed) -> Messages
fn from(v: Unsubscribed) -> Messages
Converts to this type from the input type.
source§impl From<WampResult> for Messages
impl From<WampResult> for Messages
source§fn from(v: WampResult) -> Self
fn from(v: WampResult) -> Self
Converts to this type from the input type.
source§impl PartialEq for Messages
impl PartialEq for Messages
source§impl TryFrom<Messages> for WampResult
impl TryFrom<Messages> for WampResult
impl Eq for Messages
impl StructuralEq for Messages
impl StructuralPartialEq for Messages
Auto Trait Implementations§
impl RefUnwindSafe for Messages
impl Send for Messages
impl Sync for Messages
impl Unpin for Messages
impl UnwindSafe for Messages
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