webrtc_ice/use_candidate/
mod.rs

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