pub struct MessageMethod(/* private fields */);
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§
source§impl Clone for MessageMethod
impl Clone for MessageMethod
source§fn clone(&self) -> MessageMethod
fn clone(&self) -> MessageMethod
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 MessageMethod
impl Debug for MessageMethod
source§impl Default for MessageMethod
impl Default for MessageMethod
source§fn default() -> MessageMethod
fn default() -> MessageMethod
Returns the “default value” for a type. Read more
source§impl PartialEq for MessageMethod
impl PartialEq for MessageMethod
source§impl TryFrom<u16> for MessageMethod
impl TryFrom<u16> for MessageMethod
impl Copy for MessageMethod
impl Eq for MessageMethod
impl StructuralPartialEq for MessageMethod
Auto Trait Implementations§
impl Freeze for MessageMethod
impl RefUnwindSafe for MessageMethod
impl Send for MessageMethod
impl Sync for MessageMethod
impl Unpin for MessageMethod
impl UnwindSafe for MessageMethod
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
)