pub enum RTCIceConnectionState {
Unspecified,
New,
Checking,
Connected,
Completed,
Disconnected,
Failed,
Closed,
}Expand description
Indicates the state of the ICE connection.
RTCIceConnectionState describes the current state of the ICE (Interactive
Connectivity Establishment) transport layer, which is responsible for establishing
network connectivity between peers through NAT traversal.
§State Transitions
The ICE connection typically progresses through these states:
- New - Initial state, no connectivity checks yet
- Checking - ICE agent is checking candidate pairs
- Connected - At least one working candidate pair found
- Completed - ICE has finished checking all candidates
The connection may also enter error states:
- Disconnected - Connectivity lost but recovery possible
- Failed - All candidate pairs failed, connection cannot be established
- Closed - Connection has been closed
§Examples
§Monitoring ICE State Changes
use rtc::peer_connection::state::RTCIceConnectionState;
use rtc::peer_connection::event::RTCPeerConnectionEvent;
match event {
RTCPeerConnectionEvent::OnIceConnectionStateChangeEvent(state) => {
match state {
RTCIceConnectionState::New => {
println!("ICE connectivity checking not started");
}
RTCIceConnectionState::Checking => {
println!("ICE agent is checking connectivity...");
}
RTCIceConnectionState::Connected => {
println!("ICE connected! Media can flow.");
}
RTCIceConnectionState::Completed => {
println!("ICE finished checking all candidates");
}
RTCIceConnectionState::Disconnected => {
println!("ICE connection lost - may reconnect");
}
RTCIceConnectionState::Failed => {
println!("ICE failed - cannot establish connection");
}
RTCIceConnectionState::Closed => {
println!("ICE connection closed");
}
_ => {}
}
}
_ => {}
}§String Conversion
use rtc::peer_connection::state::RTCIceConnectionState;
// Convert state to string
let state = RTCIceConnectionState::Connected;
assert_eq!(state.to_string(), "connected");
// Parse from string
let parsed: RTCIceConnectionState = "checking".into();
assert_eq!(parsed, RTCIceConnectionState::Checking);§Checking for Active Connection
use rtc::peer_connection::state::RTCIceConnectionState;
fn is_ice_active(state: RTCIceConnectionState) -> bool {
matches!(
state,
RTCIceConnectionState::Connected | RTCIceConnectionState::Completed
)
}
assert!(is_ice_active(RTCIceConnectionState::Connected));
assert!(is_ice_active(RTCIceConnectionState::Completed));
assert!(!is_ice_active(RTCIceConnectionState::Disconnected));§Specifications
Variants§
Unspecified
State not specified. This should not occur in normal operation.
New
ICE agent is gathering addresses or waiting to be given remote candidates.
This is the initial state before connectivity checks begin. Any of the ICE transports are in the “new” state and none are in “checking”, “disconnected”, or “failed” state, or all ICE transports are in the “closed” state, or there are no transports.
Checking
ICE agent has been given remote candidates and is checking pairs.
The ICE agent is actively checking candidate pairs to find a working connection. At least one ICE transport is in the “checking” state and none are in “disconnected” or “failed” state.
Connected
ICE agent has found a usable connection for all components.
A working candidate pair has been found and is being used for communication. All ICE transports are in “connected”, “completed”, or “closed” state, and at least one is in the “connected” state.
Media can flow in this state.
Completed
ICE agent has finished gathering and checking candidates.
The ICE agent has finished checking all candidate pairs and found working connections. All ICE transports are in “completed” or “closed” state, and at least one is in “completed” state.
This is a more stable state than Connected.
Disconnected
ICE connection has been lost, but recovery may be possible.
The connection was working but has been lost. The ICE agent may be able to re-establish connectivity through ICE restart. At least one ICE transport is in “disconnected” state and none are in “failed” state.
Consider triggering ICE restart if this state persists.
Failed
ICE agent has determined that connection is not possible.
All candidate pairs have failed connectivity checks. At least one ICE transport is in the “failed” state. Connection cannot be established without ICE restart.
This typically indicates NAT/firewall issues or network problems.
Closed
ICE agent has shut down and is no longer processing candidates.
The peer connection’s isClosed is true. No further ICE processing
will occur.
Trait Implementations§
Source§impl Clone for RTCIceConnectionState
impl Clone for RTCIceConnectionState
Source§fn clone(&self) -> RTCIceConnectionState
fn clone(&self) -> RTCIceConnectionState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for RTCIceConnectionState
Source§impl Debug for RTCIceConnectionState
impl Debug for RTCIceConnectionState
Source§impl Default for RTCIceConnectionState
impl Default for RTCIceConnectionState
Source§fn default() -> RTCIceConnectionState
fn default() -> RTCIceConnectionState
Source§impl Display for RTCIceConnectionState
impl Display for RTCIceConnectionState
impl Eq for RTCIceConnectionState
Source§impl From<&str> for RTCIceConnectionState
takes a string and converts it to iceconnection_state
impl From<&str> for RTCIceConnectionState
takes a string and converts it to iceconnection_state
Source§impl From<ConnectionState> for RTCIceConnectionState
impl From<ConnectionState> for RTCIceConnectionState
Source§fn from(raw: ConnectionState) -> Self
fn from(raw: ConnectionState) -> Self
Source§impl From<u8> for RTCIceConnectionState
impl From<u8> for RTCIceConnectionState
Source§impl PartialEq for RTCIceConnectionState
impl PartialEq for RTCIceConnectionState
impl StructuralPartialEq for RTCIceConnectionState
Auto Trait Implementations§
impl Freeze for RTCIceConnectionState
impl RefUnwindSafe for RTCIceConnectionState
impl Send for RTCIceConnectionState
impl Sync for RTCIceConnectionState
impl Unpin for RTCIceConnectionState
impl UnsafeUnpin for RTCIceConnectionState
impl UnwindSafe for RTCIceConnectionState
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.