openrtc 2.8.0

OpenRTC: a Rust-first P2P runtime for device discovery, signaling, and iroh/QUIC networking.
Documentation
#![cfg(not(target_arch = "wasm32"))]

use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct WebRTCSignalMessage {
    #[serde(default = "default_webrtc_transport")]
    pub transport: String,
    #[serde(rename = "type")]
    pub signal_type: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub negotiation_id: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sdp: Option<serde_json::Value>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub candidate: Option<serde_json::Value>,
}

fn default_webrtc_transport() -> String {
    "webrtc".to_string()
}

pub type WebRtcSignalSender = std::sync::Arc<
    dyn Fn(serde_json::Value) -> futures::future::BoxFuture<'static, ()> + Send + Sync,
>;

pub type WebRtcMessageHandler =
    std::sync::Arc<dyn Fn(bytes::Bytes) -> futures::future::BoxFuture<'static, ()> + Send + Sync>;

pub type WebRtcInterceptor =
    std::sync::Arc<dyn Fn(bytes::Bytes) -> futures::future::BoxFuture<'static, bool> + Send + Sync>;

pub type MoqMessageHandler =
    std::sync::Arc<dyn Fn(bytes::Bytes) -> futures::future::BoxFuture<'static, ()> + Send + Sync>;

pub type MoqTerminalHandler =
    std::sync::Arc<dyn Fn() -> futures::future::BoxFuture<'static, ()> + Send + Sync>;

#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub enum NativeWebRTCState {
    Idle,
    Connecting,
    Connected,
    Failed,
    Closed,
}

#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub enum NativeMoQState {
    Idle,
    Connecting,
    Connected,
    Failed,
    Closed,
}

#[cfg(all(not(target_arch = "wasm32"), feature = "transport-webrtc"))]
pub mod webrtc;

#[cfg(all(not(target_arch = "wasm32"), feature = "transport-webrtc"))]
pub use webrtc::{NativeWebRTCRole, WebRtcDataChannel};

#[cfg(all(not(target_arch = "wasm32"), feature = "transport-moq"))]
pub mod moq;

#[cfg(all(not(target_arch = "wasm32"), feature = "transport-moq"))]
pub use moq::NativeMoQSession;

pub fn webrtc_enabled() -> bool {
    cfg!(feature = "transport-webrtc")
}

pub fn moq_enabled() -> bool {
    cfg!(feature = "transport-moq")
}

pub fn lan_enabled() -> bool {
    cfg!(feature = "transport-lan")
}