1 #[cfg(test)] 2 mod use_candidate_test; 3 4 use stun::attributes::ATTR_USE_CANDIDATE; 5 use stun::message::*; 6 7 /// Represents USE-CANDIDATE attribute. 8 #[derive(Default)] 9 pub struct UseCandidateAttr; 10 11 impl Setter for UseCandidateAttr { 12 /// Adds USE-CANDIDATE attribute to message. add_to(&self, m: &mut Message) -> Result<(), stun::Error>13 fn add_to(&self, m: &mut Message) -> Result<(), stun::Error> { 14 m.add(ATTR_USE_CANDIDATE, &[]); 15 Ok(()) 16 } 17 } 18 19 impl UseCandidateAttr { 20 #[must_use] new() -> Self21 pub const fn new() -> Self { 22 Self 23 } 24 25 /// Returns true if USE-CANDIDATE attribute is set. 26 #[must_use] is_set(m: &Message) -> bool27 pub fn is_set(m: &Message) -> bool { 28 let result = m.get(ATTR_USE_CANDIDATE); 29 result.is_ok() 30 } 31 } 32