Skip to main content

rtc_ice/attributes/use_candidate/
mod.rs

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