Struct stun_rs::MessageType
source · [−]pub struct MessageType { /* private fields */ }Expand description
The message type defines the message class (request, success response, error response, or indication) and the message method (the primary function) of the STUN message. Although there are four message classes, there are only two types of transactions in STUN: request/response transactions (which consist of a request message and a response message) and indication transactions (which consist of a single indication message). Response classes are split into error and success responses to aid in quickly processing the STUN message.
Examples
let msg_type = MessageType::new(BINDING, MessageClass::SuccessResponse);
assert_eq!(msg_type.as_u16(), 0x0101);
assert_eq!(msg_type.method(), BINDING);
assert_eq!(msg_type.class(), MessageClass::SuccessResponse);Implementations
sourceimpl MessageType
impl MessageType
sourcepub fn new(method: MessageMethod, class: MessageClass) -> Self
pub fn new(method: MessageMethod, class: MessageClass) -> Self
sourcepub fn class(&self) -> MessageClass
pub fn class(&self) -> MessageClass
Returns the message class.
sourcepub fn method(&self) -> MessageMethod
pub fn method(&self) -> MessageMethod
Returns the message method
sourcepub fn as_u16(&self) -> u16
pub fn as_u16(&self) -> u16
Returns the u16 representation of this MessageType
Trait Implementations
sourceimpl Clone for MessageType
impl Clone for MessageType
sourcefn clone(&self) -> MessageType
fn clone(&self) -> MessageType
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresourceimpl Debug for MessageType
impl Debug for MessageType
sourceimpl From<&[u8; 2]> for MessageType
impl From<&[u8; 2]> for MessageType
sourceimpl From<u16> for MessageType
impl From<u16> for MessageType
sourceimpl PartialEq<MessageType> for MessageType
impl PartialEq<MessageType> for MessageType
sourcefn eq(&self, other: &MessageType) -> bool
fn eq(&self, other: &MessageType) -> bool
impl Copy for MessageType
impl Eq for MessageType
impl StructuralEq for MessageType
impl StructuralPartialEq for MessageType
Auto Trait Implementations
impl RefUnwindSafe for MessageType
impl Send for MessageType
impl Sync for MessageType
impl Unpin for MessageType
impl UnwindSafe for MessageType
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more