pub struct Candidate { /* private fields */ }Expand description
One ICE candidate: a transport address this agent can be reached at, or can reach a peer at, together with its type, priority and liveness bookkeeping.
Implementations§
Source§impl Candidate
impl Candidate
Sourcepub fn foundation(&self) -> String
pub fn foundation(&self) -> String
The candidate’s foundation (RFC 8445 Section 5.1.1.3): two candidates have the same one when they have the same type, their bases have the same IP address (ports may differ), they came from the same STUN or TURN server (reflexive and relayed ones) and they use the same transport protocol.
A host candidate’s base is itself (an mDNS name stands for its address); a reflexive candidate’s base is its related address; a relayed candidate’s base is the relayed address. A foundation groups equivalent candidates; it is deterministic bookkeeping rather than a secret, random identifier. CRC-32C is therefore intentional here.
Sourcepub fn set_component(&mut self, component: u16)
pub fn set_component(&mut self, component: u16)
Sets candidate component.
Sourcepub fn last_received(&self) -> Option<Instant>
pub fn last_received(&self) -> Option<Instant>
When traffic was last received on this candidate.
None until the first packet arrives. A freshly constructed or freshly parsed candidate
has not received anything, and previously said it had — it was seeded with the
construction instant, which also meant every candidate constructor needed a clock.
Sourcepub fn last_sent(&self) -> Option<Instant>
pub fn last_sent(&self) -> Option<Instant>
When traffic was last sent on this candidate, or None if none ever has been.
Sourcepub fn network_type(&self) -> NetworkType
pub fn network_type(&self) -> NetworkType
Returns candidate NetworkType.
Sourcepub fn type_preference(&self, candidate_type: CandidateType) -> u16
pub fn type_preference(&self, candidate_type: CandidateType) -> u16
The type preference of candidate_type on this candidate’s transport. RFC 6544
section 4.2: “the type preferences for the preferred transport protocol candidates
SHOULD be increased and/or the type preferences for the other transport protocol
candidates SHOULD be decreased … changing type preference values by one for the other
transport protocol candidates is enough” when the candidate type matters more, and “For
RTP-based media streams, it is RECOMMENDED that UDP candidates are preferred over TCP
candidates”. A TCP candidate takes the UDP type preference less one (host 125,
peer-reflexive 109, server-reflexive 99): a TCP host candidate still outranks a UDP
server-reflexive one, a UDP candidate outranks the TCP one of its type. A relayed TCP
candidate stays at 0 (“relayed candidates are still preferred lower than the other
candidate types”), below the UDP relayed one by its local preference.
Sourcepub fn peer_reflexive_priority(&self) -> u32
pub fn peer_reflexive_priority(&self) -> u32
The priority this candidate would have as a peer-reflexive one: the value of the PRIORITY attribute in a connectivity check sent from it (RFC 8445 Section 7.1.1). The peer-reflexive type preference (of its transport, RFC 6544 section 4.2), with this candidate’s local preference and component.
Returns Option<CandidateRelatedAddress>.
Sourcepub fn candidate_type(&self) -> CandidateType
pub fn candidate_type(&self) -> CandidateType
Returns candidate type.
Sourcepub fn set_tcp_type(&mut self, tcp_type: TcpType)
pub fn set_tcp_type(&mut self, tcp_type: TcpType)
Sets the TCP role of an ICE-TCP candidate of any type (RFC 6544 Section 4.5: every TCP
candidate is signalled with a tcptype).
Sourcepub fn url(&self) -> Option<&str>
pub fn url(&self) -> Option<&str>
The STUN or TURN server this candidate was gathered from, if any.
The related address to signal and to show in statistics: the candidate’s own, or,
when its base is a host address hidden behind an mDNS name, 0.0.0.0 (::) and port
9 (draft-ietf-mmusic-mdns-ice-candidates Section 3.1.2.2: “the agent MUST set the
rel-addr and rel-port fields of the candidate to 0.0.0.0/:: and 9”).
Sourcepub fn addr(&self) -> SocketAddr
pub fn addr(&self) -> SocketAddr
The candidate’s socket address.
Sourcepub fn base_addr(&self) -> SocketAddr
pub fn base_addr(&self) -> SocketAddr
Returns the candidate’s base address: the local transport address the candidate was derived from, i.e. the address packets for this candidate must be sent from (RFC 8445 §5.1.1).
For server-reflexive and peer-reflexive candidates this is the related (host) address; for host and relay candidates the base is the candidate address itself.
Source§impl Candidate
impl Candidate
Sourcepub fn last_authenticated(&self) -> Option<Instant>
pub fn last_authenticated(&self) -> Option<Instant>
When an authenticated Binding request or response last arrived from this candidate.
Sourcepub fn last_consent(&self) -> Option<Instant>
pub fn last_consent(&self) -> Option<Instant>
When a success response to one of our Binding requests last arrived from this candidate: the last time the peer granted consent (RFC 7675).
Sourcepub fn set_last_received(&mut self, now: Instant)
pub fn set_last_received(&mut self, now: Instant)
Records that traffic was received on this candidate at now.
Sourcepub fn set_last_sent(&mut self, now: Instant)
pub fn set_last_sent(&mut self, now: Instant)
Records that traffic was sent on this candidate at now.
Sourcepub fn set_local_preference_rank(&mut self, rank: u16)
pub fn set_local_preference_rank(&mut self, rank: u16)
Ranks this candidate among the local candidates of its type: 0 is the most preferred (local preference 65535 for UDP, other-pref 8191 for TCP), each further rank one less.
RFC 8445 Section 5.1.2.1 wants a unique local preference for each candidate of a type,
and RFC 8421 wants candidates from an unreliable interface last. A candidate the
application does not rank (and gives no priority) is ranked by
Agent::add_local_candidate, in the order it is
added, IPv4 and IPv6 interleaved.
Sourcepub fn local_preference_rank(&self) -> Option<u16>
pub fn local_preference_rank(&self) -> Option<u16>
The rank set by Candidate::set_local_preference_rank or by the agent.
Sourcepub fn local_preference(&self) -> u16
pub fn local_preference(&self) -> u16
Returns the local preference for this candidate.