Trait rustun::attribute::Attribute
[−]
[src]
pub trait Attribute: Sized { fn get_type(&self) -> Type; fn try_from_raw(attr: &RawAttribute, message: &RawMessage) -> Result<Self>; fn encode_value(&self, message: &RawMessage) -> Result<Vec<u8>>; fn try_to_raw(&self, message: &RawMessage) -> Result<RawAttribute> { ... } }
STUN attribute.
Attribute: The STUN term for a Type-Length-Value (TLV) object that can be added to a STUN message. Attributes are divided into two types: comprehension-required and comprehension-optional. STUN agents can safely ignore comprehension-optional attributes they don't understand, but cannot successfully process a message if it contains comprehension-required attributes that are not understood.
Required Methods
fn get_type(&self) -> Type
Returns the attribute type of this instance.
fn try_from_raw(attr: &RawAttribute, message: &RawMessage) -> Result<Self>
Tries to convert from RawAttribute
.
The message
is a RawMessage
instance which contains attr
.
The attributes contained in message
are those that precede attr
.
fn encode_value(&self, message: &RawMessage) -> Result<Vec<u8>>
Tries to encode the value of this attribute to bytes.
Provided Methods
fn try_to_raw(&self, message: &RawMessage) -> Result<RawAttribute>
Tries to convert to RawAttribute
.
The resulting attribute will be added at the tail of the attribute of the message
.
Implementors
impl Attribute for RawAttribute
impl Attribute for MappedAddress
impl Attribute for AlternateServer
impl Attribute for Username
impl Attribute for MessageIntegrity
impl Attribute for ErrorCode
impl Attribute for UnknownAttributes
impl Attribute for Realm
impl Attribute for Nonce
impl Attribute for Fingerprint
impl Attribute for Software
impl Attribute for XorMappedAddress
impl Attribute for Attribute