rtc 0.21.0-alpha.2

Sans-I/O WebRTC implementation in Rust
Documentation
use std::fmt;

use super::candidate::*;

/// ICECandidatePair represents an ICE Candidate pair
///
/// ## Specifications
///
/// * [MDN]
///
/// [MDN]: https://developer.mozilla.org/en-US/docs/Web/API/RTCIceCandidatePair
#[derive(Default, Debug, Clone, PartialEq, Eq)]
pub struct RTCIceCandidatePair {
    local: RTCIceCandidate,
    remote: RTCIceCandidate,
}

impl fmt::Display for RTCIceCandidatePair {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "(local) {} <-> (remote) {}", self.local, self.remote)
    }
}

impl RTCIceCandidatePair {
    /// returns an initialized ICECandidatePair
    /// for the given pair of ICECandidate instances
    pub fn new(local: RTCIceCandidate, remote: RTCIceCandidate) -> Self {
        RTCIceCandidatePair { local, remote }
    }

    /// The local candidate of the pair.
    pub fn local(&self) -> &RTCIceCandidate {
        &self.local
    }

    /// The remote candidate of the pair.
    pub fn remote(&self) -> &RTCIceCandidate {
        &self.remote
    }
}