pub struct Candidate { /* private fields */ }
Expand description
ICE candidates are network addresses used to connect to a peer.
There are different kinds of ICE candidates. The simplest kind is a host candidate which is a socket address on a local (host) network interface.
Implementations§
Source§impl Candidate
impl Candidate
Sourcepub fn host(
addr: SocketAddr,
proto: impl TryInto<Protocol>,
) -> Result<Self, IceError>
pub fn host( addr: SocketAddr, proto: impl TryInto<Protocol>, ) -> Result<Self, IceError>
Creates a host ICE candidate.
Host candidates are local sockets directly on the host.
Sourcepub fn server_reflexive(
addr: SocketAddr,
base: SocketAddr,
proto: impl TryInto<Protocol>,
) -> Result<Self, IceError>
pub fn server_reflexive( addr: SocketAddr, base: SocketAddr, proto: impl TryInto<Protocol>, ) -> Result<Self, IceError>
Creates a server reflexive ICE candidate.
Server reflexive candidates are local sockets mapped to external ip discovered
via a STUN binding request.
The base
is the local interface that this address corresponds to.
Sourcepub fn relayed(
addr: SocketAddr,
proto: impl TryInto<Protocol>,
) -> Result<Self, IceError>
pub fn relayed( addr: SocketAddr, proto: impl TryInto<Protocol>, ) -> Result<Self, IceError>
Creates a relayed ICE candidate.
Relayed candidates are server sockets relaying traffic to a local socket. Allocate a TURN addr to use as a local candidate.
Sourcepub fn from_sdp_string(s: &str) -> Result<Self, IceError>
pub fn from_sdp_string(s: &str) -> Result<Self, IceError>
Creates a new ICE candidate from a string.
Sourcepub fn prio(&self) -> u32
pub fn prio(&self) -> u32
Returns the priority value for the specified ICE candidate.
The priority is a positive integer between 1 and 2^31 - 1 (inclusive), calculated according to the ICE specification defined in RFC 8445, Section 5.1.2.
Sourcepub fn addr(&self) -> SocketAddr
pub fn addr(&self) -> SocketAddr
Returns the address for the specified ICE candidate.
Sourcepub fn proto(&self) -> Protocol
pub fn proto(&self) -> Protocol
Returns a reference to the String containing the transport protocol of the ICE candidate. For example tcp/udp/..
Sourcepub fn kind(&self) -> CandidateKind
pub fn kind(&self) -> CandidateKind
Returns the kind of this candidate.
Sourcepub fn to_sdp_string(&self) -> String
pub fn to_sdp_string(&self) -> String
Generates a candidate attribute string.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Candidate
Deserialize Candidate from a candidate info.
impl<'de> Deserialize<'de> for Candidate
Deserialize Candidate from a candidate info.
Similar to Candidate::serialize, we drop sdpMid
and sdpMLineIndex
when parsing.
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl Serialize for Candidate
Serialize Candidate into candidate info.
impl Serialize for Candidate
Serialize Candidate into candidate info.
Always set sdpMid
to null and sdpMLineIndex
to 0, as we only support one media line.
e.g. serde_json would produce:
{
"candidate": "candidate:12044049749558888150 1 udp 2130706175 1.2.3.4 1234 typ host",
"sdpMid": null,
"sdpMLineIndex": 0
"usernameFragment": "ufrag"
}