pub struct MessageType(/* private fields */);
Expand description
The type of a Message
. A combination of a MessageClass
and a STUN method.
Implementations§
Source§impl MessageType
impl MessageType
Sourcepub fn from_class_method(class: MessageClass, method: Method) -> Self
pub fn from_class_method(class: MessageClass, method: Method) -> Self
Create a new MessageType
from the provided MessageClass
and method
§Examples
let mtype = MessageType::from_class_method(MessageClass::Indication, BINDING);
assert_eq!(mtype.has_class(MessageClass::Indication), true);
assert_eq!(mtype.has_method(BINDING), true);
Sourcepub fn class(self) -> MessageClass
pub fn class(self) -> MessageClass
Retrieves the class of a MessageType
§Examples
let mtype = MessageType::from_class_method(MessageClass::Indication, BINDING);
assert_eq!(mtype.class(), MessageClass::Indication);
Sourcepub fn has_class(self, cls: MessageClass) -> bool
pub fn has_class(self, cls: MessageClass) -> bool
Returns whether class of a MessageType
is equal to the provided MessageClass
§Examples
let mtype = MessageType::from_class_method(MessageClass::Indication, BINDING);
assert!(mtype.has_class(MessageClass::Indication));
Sourcepub fn is_response(self) -> bool
pub fn is_response(self) -> bool
Returns whether the class of a MessageType
indicates a response Message
§Examples
assert_eq!(MessageType::from_class_method(MessageClass::Indication, BINDING)
.is_response(), false);
assert_eq!(MessageType::from_class_method(MessageClass::Request, BINDING)
.is_response(), false);
assert_eq!(MessageType::from_class_method(MessageClass::Success, BINDING)
.is_response(), true);
assert_eq!(MessageType::from_class_method(MessageClass::Error, BINDING)
.is_response(), true);
Sourcepub fn method(self) -> Method
pub fn method(self) -> Method
Returns the method of a MessageType
§Examples
let mtype = MessageType::from_class_method(MessageClass::Indication, BINDING);
assert_eq!(mtype.method(), BINDING);
Sourcepub fn has_method(self, method: Method) -> bool
pub fn has_method(self, method: Method) -> bool
Returns whether the method of a MessageType
is equal to the provided value
§Examples
let mtype = MessageType::from_class_method(MessageClass::Indication, BINDING);
assert_eq!(mtype.has_method(BINDING), true);
Sourcepub fn write_into(&self, dest: &mut [u8])
pub fn write_into(&self, dest: &mut [u8])
Convert a MessageType
to network bytes
Sourcepub fn from_bytes(data: &[u8]) -> Result<Self, StunParseError>
pub fn from_bytes(data: &[u8]) -> Result<Self, StunParseError>
Convert a set of network bytes into a MessageType
or return an error
Trait Implementations§
Source§impl Clone for MessageType
impl Clone for MessageType
Source§fn clone(&self) -> MessageType
fn clone(&self) -> MessageType
Returns a duplicate 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 Display for MessageType
impl Display for MessageType
Source§impl PartialEq for MessageType
impl PartialEq for MessageType
Source§impl TryFrom<&[u8]> for MessageType
impl TryFrom<&[u8]> 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