stun_rs/attributes/ice/
priority.rs

1const PRIORITY: u16 = 0x0024;
2
3crate::common::integer_attribute!(
4    /// The [`Priority`] attribute MUST be included in a Binding request and be
5    /// set to the value computed by the algorithm in
6    /// [Section 5.1.2](https://datatracker.ietf.org/doc/html/rfc8445#section-5.1.2)
7    /// for the local candidate, but with the candidate type preference of
8    /// peer-reflexive candidates.
9    ///
10    /// # Examples
11    ///```rust
12    /// # use stun_rs::attributes::ice::Priority;
13    /// let attr = Priority::from(1234);
14    /// assert_eq!(attr, 1234);
15    ///```
16    Priority,
17    PRIORITY,
18    u32,
19);
20
21#[cfg(test)]
22mod tests {
23    use super::*;
24    use crate::StunAttribute;
25
26    #[test]
27    fn priority_stunt_attribute() {
28        let attr = StunAttribute::Priority(Priority::from(1234));
29        assert!(attr.is_priority());
30        assert!(attr.as_priority().is_ok());
31        assert!(attr.as_error_code().is_err());
32
33        assert!(attr.attribute_type().is_comprehension_required());
34        assert!(!attr.attribute_type().is_comprehension_optional());
35
36        let dbg_fmt = format!("{:?}", attr);
37        assert_eq!("Priority(Priority(1234))", dbg_fmt);
38    }
39}