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§
source§impl 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§
source§impl Clone for MessageType
impl Clone for MessageType
source§fn clone(&self) -> MessageType
fn clone(&self) -> MessageType
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for MessageType
impl Debug for MessageType
source§impl From<u16> for MessageType
impl From<u16> for MessageType
source§impl PartialEq for MessageType
impl PartialEq for MessageType
impl Copy for MessageType
impl Eq for MessageType
impl StructuralPartialEq for MessageType
Auto Trait Implementations§
impl Freeze for MessageType
impl RefUnwindSafe for MessageType
impl Send for MessageType
impl Sync for MessageType
impl Unpin for MessageType
impl UnwindSafe for MessageType
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)