pub struct AttributeType(/* private fields */);
Implementations§
Source§impl AttributeType
impl AttributeType
Sourcepub fn add_name(self, name: &'static str)
pub fn add_name(self, name: &'static str)
Add the name for a particular AttributeType
for formatting purposes.
Sourcepub const fn new(val: u16) -> Self
pub const fn new(val: u16) -> Self
Create a new AttributeType from an existing value
Note: the value passed in is not encoded as in a stun message
§Examples
assert_eq!(AttributeType::new(0x123).value(), 0x123);
Sourcepub fn value(&self) -> u16
pub fn value(&self) -> u16
Return the integer value of this AttributeType
Note: the value returned is not encoded as in a stun message
§Examples
assert_eq!(AttributeType::new(0x123).value(), 0x123);
Sourcepub fn name(self) -> &'static str
pub fn name(self) -> &'static str
Returns a human readable name of this AttributeType
or “unknown”
§Examples
assert_eq!(XorMappedAddress::TYPE.name(), "XOR-MAPPED-ADDRESS");
Sourcepub fn comprehension_required(self) -> bool
pub fn comprehension_required(self) -> bool
Check if comprehension is required for an AttributeType
. All attribute
values < 0x8000 require comprehension.
§Examples
assert_eq!(AttributeType::new(0x0).comprehension_required(), true);
assert_eq!(AttributeType::new(0x8000).comprehension_required(), false);
Trait Implementations§
Source§impl Clone for AttributeType
impl Clone for AttributeType
Source§fn clone(&self) -> AttributeType
fn clone(&self) -> AttributeType
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 AttributeType
impl Debug for AttributeType
Source§impl Display for AttributeType
impl Display for AttributeType
Source§impl From<AttributeType> for u16
impl From<AttributeType> for u16
Source§fn from(f: AttributeType) -> Self
fn from(f: AttributeType) -> Self
Converts to this type from the input type.
Source§impl From<u16> for AttributeType
impl From<u16> for AttributeType
Source§impl Hash for AttributeType
impl Hash for AttributeType
Source§impl Ord for AttributeType
impl Ord for AttributeType
Source§fn cmp(&self, other: &AttributeType) -> Ordering
fn cmp(&self, other: &AttributeType) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for AttributeType
impl PartialEq for AttributeType
Source§impl PartialOrd for AttributeType
impl PartialOrd for AttributeType
impl Copy for AttributeType
impl Eq for AttributeType
impl StructuralPartialEq for AttributeType
Auto Trait Implementations§
impl Freeze for AttributeType
impl RefUnwindSafe for AttributeType
impl Send for AttributeType
impl Sync for AttributeType
impl Unpin for AttributeType
impl UnwindSafe for AttributeType
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