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

Returns the u16 representation of this message method.

Returns true if the method is within the valid range 0x00-0xFF

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
The type returned in the event of a conversion error.
Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.