From 5a29845c187b37709799a4c304e580e7807f6670 Mon Sep 17 00:00:00 2001 From: yngrtc Date: Sat, 9 Mar 2024 08:12:50 -0800 Subject: [PATCH] fix rtc-ic/state_test.rs --- rtc-ice/src/agent/mod.rs | 2 +- rtc-ice/src/lib.rs | 2 +- .../src/{connection_state => state}/mod.rs | 44 +++++++++++++++++++ .../{connection_state => state}/state_test.rs | 0 4 files changed, 46 insertions(+), 2 deletions(-) rename rtc-ice/src/{connection_state => state}/mod.rs (62%) rename rtc-ice/src/{connection_state => state}/state_test.rs (100%) diff --git a/rtc-ice/src/agent/mod.rs b/rtc-ice/src/agent/mod.rs index 18145bc..f1b55fa 100644 --- a/rtc-ice/src/agent/mod.rs +++ b/rtc-ice/src/agent/mod.rs @@ -22,8 +22,8 @@ use stun::xoraddr::*; use crate::agent::agent_transport::*; use crate::candidate::*; -use crate::connection_state::*; use crate::rand::*; +use crate::state::*; use crate::url::*; use shared::error::*; diff --git a/rtc-ice/src/lib.rs b/rtc-ice/src/lib.rs index facf90e..af1477e 100644 --- a/rtc-ice/src/lib.rs +++ b/rtc-ice/src/lib.rs @@ -4,7 +4,7 @@ pub mod agent; pub mod attributes; pub mod candidate; -pub mod connection_state; pub mod rand; +pub mod state; pub mod stats; pub mod url; diff --git a/rtc-ice/src/connection_state/mod.rs b/rtc-ice/src/state/mod.rs similarity index 62% rename from rtc-ice/src/connection_state/mod.rs rename to rtc-ice/src/state/mod.rs index 721a317..bf21877 100644 --- a/rtc-ice/src/connection_state/mod.rs +++ b/rtc-ice/src/state/mod.rs @@ -66,3 +66,47 @@ impl From for ConnectionState { } } } + +/// Describes the state of the candidate gathering process. +#[derive(PartialEq, Eq, Copy, Clone)] +pub enum GatheringState { + Unspecified, + + /// Indicates candidate gathering is not yet started. + New, + + /// Indicates candidate gathering is ongoing. + Gathering, + + /// Indicates candidate gathering has been completed. + Complete, +} + +impl From for GatheringState { + fn from(v: u8) -> Self { + match v { + 1 => Self::New, + 2 => Self::Gathering, + 3 => Self::Complete, + _ => Self::Unspecified, + } + } +} + +impl Default for GatheringState { + fn default() -> Self { + Self::Unspecified + } +} + +impl fmt::Display for GatheringState { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let s = match *self { + Self::New => "new", + Self::Gathering => "gathering", + Self::Complete => "complete", + Self::Unspecified => "unspecified", + }; + write!(f, "{s}") + } +} diff --git a/rtc-ice/src/connection_state/state_test.rs b/rtc-ice/src/state/state_test.rs similarity index 100% rename from rtc-ice/src/connection_state/state_test.rs rename to rtc-ice/src/state/state_test.rs