Struct librice::stun::attribute::UnknownAttributes
source · pub struct UnknownAttributes { /* private fields */ }
Expand description
The UnknownAttributes Attribute
Implementations§
source§impl UnknownAttributes
impl UnknownAttributes
sourcepub fn new(attrs: &[AttributeType]) -> Self
pub fn new(attrs: &[AttributeType]) -> Self
Create a new unknown attributes Attribute
Examples
let unknown = UnknownAttributes::new(&[USERNAME]);
assert!(unknown.has_attribute(USERNAME));
Examples found in repository?
src/stun/message.rs (line 1016)
1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019
pub fn unknown_attributes(
src: &Message,
attributes: &[AttributeType],
) -> Result<Message, StunError> {
let mut out = Message::new_error(src);
out.add_attribute(Software::new("stund - librice v0.1")?)?;
out.add_attribute(ErrorCode::new(420, "Unknown Attributes")?)?;
if !attributes.is_empty() {
out.add_attribute(UnknownAttributes::new(attributes))?;
}
Ok(out)
}
sourcepub fn add_attribute(&mut self, attr: AttributeType)
pub fn add_attribute(&mut self, attr: AttributeType)
Add an AttributeType
that is unsupported
Examples
let mut unknown = UnknownAttributes::new(&[]);
unknown.add_attribute(USERNAME);
assert!(unknown.has_attribute(USERNAME));
sourcepub fn has_attribute(&self, attr: AttributeType) -> bool
pub fn has_attribute(&self, attr: AttributeType) -> bool
Check if an AttributeType
is present
Examples
let unknown = UnknownAttributes::new(&[USERNAME]);
assert!(unknown.has_attribute(USERNAME));
Trait Implementations§
source§impl Attribute for UnknownAttributes
impl Attribute for UnknownAttributes
source§fn get_type(&self) -> AttributeType
fn get_type(&self) -> AttributeType
Retrieve the
AttributeType
of an Attribute
source§fn length(&self) -> u16
fn length(&self) -> u16
Retrieve the length of an
Attribute
. This is not the padded length as stored in a
Message
source§fn to_raw(&self) -> RawAttribute
fn to_raw(&self) -> RawAttribute
Convert an
Attribute
to a RawAttribute
source§fn from_raw(raw: &RawAttribute) -> Result<Self, StunParseError>
fn from_raw(raw: &RawAttribute) -> Result<Self, StunParseError>
Convert an
Attribute
from a RawAttribute
source§impl Clone for UnknownAttributes
impl Clone for UnknownAttributes
source§fn clone(&self) -> UnknownAttributes
fn clone(&self) -> UnknownAttributes
Returns a copy 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 UnknownAttributes
impl Debug for UnknownAttributes
source§impl Display for UnknownAttributes
impl Display for UnknownAttributes
source§impl From<UnknownAttributes> for RawAttribute
impl From<UnknownAttributes> for RawAttribute
source§fn from(f: UnknownAttributes) -> Self
fn from(f: UnknownAttributes) -> Self
Converts to this type from the input type.
source§impl TryFrom<&RawAttribute> for UnknownAttributes
impl TryFrom<&RawAttribute> for UnknownAttributes
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.