Struct stun_rs::MessageMethod
source · [−]pub struct MessageMethod(_);Expand description
The STUN method is a 12 bits hex number in the range 0x000-0xFFF but
valid values are defined in the range 0x00-0xFF.
STUN methods in the range 0x000-0x07F are assigned by IETF Review
RFC8126. STUN
methods in the range 0x080-0x0FF are assigned by Expert Review.
Examples
// Create a binding method
let binding = MessageMethod::try_from(0x001)?;
assert_eq!(binding.as_u16(), 0x001);
// Binding request is within the range of valid values 0x00-0xFF
assert!(binding.is_valid());
// Create a custom method
let method = MessageMethod::try_from(0x100)?;
// This method is out of the range of valid values 0x00-0xFF
assert!(!method.is_valid());
// Creating a message method out of 12 bits range 0x000-0xFFF
// will result in an error
assert_eq!(MessageMethod::try_from(0x1000).expect_err("Error expected"), StunErrorType::InvalidParam);Implementations
Trait Implementations
sourceimpl Clone for MessageMethod
impl Clone for MessageMethod
sourcefn clone(&self) -> MessageMethod
fn clone(&self) -> MessageMethod
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 MessageMethod
impl Debug for MessageMethod
sourceimpl Default for MessageMethod
impl Default for MessageMethod
sourcefn default() -> MessageMethod
fn default() -> MessageMethod
Returns the “default value” for a type. Read more
sourceimpl PartialEq<MessageMethod> for MessageMethod
impl PartialEq<MessageMethod> for MessageMethod
sourcefn eq(&self, other: &MessageMethod) -> bool
fn eq(&self, other: &MessageMethod) -> bool
sourceimpl TryFrom<u16> for MessageMethod
impl TryFrom<u16> for MessageMethod
impl Copy for MessageMethod
impl Eq for MessageMethod
impl StructuralEq for MessageMethod
impl StructuralPartialEq for MessageMethod
Auto Trait Implementations
impl RefUnwindSafe for MessageMethod
impl Send for MessageMethod
impl Sync for MessageMethod
impl Unpin for MessageMethod
impl UnwindSafe for MessageMethod
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