Trait stun_codec::Attribute [−][src]
pub trait Attribute: Sized + Clone { type Decoder: Default + TryTaggedDecode<Tag = AttributeType, Item = Self>; type Encoder: Default + SizedEncode<Item = Self>; fn get_type(&self) -> AttributeType; fn before_encode<A: Attribute>(
&mut self,
message: &Message<A>
) -> Result<()> { ... } fn after_decode<A: Attribute>(&mut self, message: &Message<A>) -> Result<()> { ... } }
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.
Associated Types
type Decoder: Default + TryTaggedDecode<Tag = AttributeType, Item = Self>
The decoder of the value part of the attribute.
type Encoder: Default + SizedEncode<Item = Self>
The encoder of the value part of the attribute.
Required Methods
fn get_type(&self) -> AttributeType
Returns the type of the attribute.
Provided Methods
fn before_encode<A: Attribute>(&mut self, message: &Message<A>) -> Result<()>
This method is called before encoding the attribute.
message
is the message to which the attribute belongs.
The message only contains the attributes preceding to self
.
The default implementation simply returns Ok(())
.
fn after_decode<A: Attribute>(&mut self, message: &Message<A>) -> Result<()>
This method is called after decoding the attribute and before being appended to the given message.
The default implementation simply returns Ok(())
.
Implementors
impl Attribute for AlternateServer type Decoder = AlternateServerDecoder; type Encoder = AlternateServerEncoder;
impl Attribute for ErrorCode type Decoder = ErrorCodeDecoder; type Encoder = ErrorCodeEncoder;
impl Attribute for Fingerprint type Decoder = FingerprintDecoder; type Encoder = FingerprintEncoder;
impl Attribute for MappedAddress type Decoder = MappedAddressDecoder; type Encoder = MappedAddressEncoder;
impl Attribute for MessageIntegrity type Decoder = MessageIntegrityDecoder; type Encoder = MessageIntegrityEncoder;
impl Attribute for Nonce type Decoder = NonceDecoder; type Encoder = NonceEncoder;
impl Attribute for Realm type Decoder = RealmDecoder; type Encoder = RealmEncoder;
impl Attribute for Software type Decoder = SoftwareDecoder; type Encoder = SoftwareEncoder;
impl Attribute for UnknownAttributes type Decoder = UnknownAttributesDecoder; type Encoder = UnknownAttributesEncoder;
impl Attribute for Username type Decoder = UsernameDecoder; type Encoder = UsernameEncoder;
impl Attribute for XorMappedAddress type Decoder = XorMappedAddressDecoder; type Encoder = XorMappedAddressEncoder;
impl Attribute for Attribute type Decoder = AttributeDecoder; type Encoder = AttributeEncoder;
impl Attribute for RawAttribute type Decoder = RawAttributeDecoder; type Encoder = RawAttributeEncoder;