pub mod web_rtc_play;
pub mod web_rtc_publish;
use derive_more::{AsRef, Display, From, Into};
use ref_cast::RefCast;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
#[doc(inline)]
pub use self::{web_rtc_play::WebRtcPlay, web_rtc_publish::WebRtcPublish};
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Endpoint {
pub id: Id,
pub spec: Spec,
}
impl From<WebRtcPlay> for Endpoint {
fn from(play: WebRtcPlay) -> Self {
Self {
id: play.id.into(),
spec: play.spec.into(),
}
}
}
impl From<WebRtcPublish> for Endpoint {
fn from(publish: WebRtcPublish) -> Self {
Self {
id: publish.id.into(),
spec: publish.spec.into(),
}
}
}
#[derive(Clone, Debug, Eq, From, PartialEq)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[cfg_attr(feature = "serde", serde(tag = "kind", content = "spec"))]
pub enum Spec {
WebRtcPublishEndpoint(web_rtc_publish::Spec),
WebRtcPlayEndpoint(web_rtc_play::Spec),
}
#[derive(
AsRef,
Clone,
Debug,
Display,
Eq,
From,
Hash,
Into,
Ord,
PartialEq,
PartialOrd,
RefCast,
)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[cfg_attr(feature = "serde", serde(transparent))]
#[from(types("&str", String, web_rtc_play::Id, web_rtc_publish::Id))]
#[into(owned(types(String, web_rtc_play::Id, web_rtc_publish::Id)))]
#[repr(transparent)]
pub struct Id(Box<str>);
impl AsRef<web_rtc_play::Id> for Id {
fn as_ref(&self) -> &web_rtc_play::Id {
web_rtc_play::Id::ref_cast(&self.0)
}
}
impl AsRef<web_rtc_publish::Id> for Id {
fn as_ref(&self) -> &web_rtc_publish::Id {
web_rtc_publish::Id::ref_cast(&self.0)
}
}