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.

RFC 5389 -- 5. Definitions

Required Methods

Returns the attribute type of this instance.

Tries to convert from RawAttribute.

The message is a RawMessage instance which contains attr. The attributes contained in message are those that precede attr.

Tries to encode the value of this attribute to bytes.

Provided Methods

Tries to convert to RawAttribute.

The resulting attribute will be added at the tail of the attribute of the message.

Implementors