Skip to main content

RTCIceConnectionState

Enum RTCIceConnectionState 

Source
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:

  1. New - Initial state, no connectivity checks yet
  2. Checking - ICE agent is checking candidate pairs
  3. Connected - At least one working candidate pair found
  4. 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

Source§

fn clone(&self) -> RTCIceConnectionState

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for RTCIceConnectionState

Source§

impl Debug for RTCIceConnectionState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RTCIceConnectionState

Source§

fn default() -> RTCIceConnectionState

Returns the “default value” for a type. Read more
Source§

impl Display for RTCIceConnectionState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for RTCIceConnectionState

Source§

impl From<&str> for RTCIceConnectionState

takes a string and converts it to iceconnection_state

Source§

fn from(raw: &str) -> Self

Converts to this type from the input type.
Source§

impl From<ConnectionState> for RTCIceConnectionState

Source§

fn from(raw: ConnectionState) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for RTCIceConnectionState

Source§

fn from(v: u8) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for RTCIceConnectionState

Source§

fn eq(&self, other: &RTCIceConnectionState) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for RTCIceConnectionState

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V