medea_control_api_proto/control/endpoint/
mod.rs1pub mod web_rtc_play;
4pub mod web_rtc_publish;
5
6use derive_more::with_trait::{AsRef, Display, From, Into};
7use ref_cast::RefCast;
8#[cfg(feature = "serde")]
9use serde::{Deserialize, Serialize};
10
11#[doc(inline)]
12pub use self::{web_rtc_play::WebRtcPlay, web_rtc_publish::WebRtcPublish};
13
14#[derive(Clone, Debug, Eq, PartialEq)]
18pub struct Endpoint {
19 pub id: Id,
23
24 pub spec: Spec,
28}
29
30impl From<WebRtcPlay> for Endpoint {
31 fn from(play: WebRtcPlay) -> Self {
32 Self { id: play.id.into(), spec: play.spec.into() }
33 }
34}
35
36impl From<WebRtcPublish> for Endpoint {
37 fn from(publish: WebRtcPublish) -> Self {
38 Self { id: publish.id.into(), spec: publish.spec.into() }
39 }
40}
41
42#[derive(Clone, Debug, Eq, From, PartialEq)]
46#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
47#[cfg_attr(feature = "serde", serde(tag = "kind", content = "spec"))]
48pub enum Spec {
49 WebRtcPublishEndpoint(web_rtc_publish::Spec),
53
54 WebRtcPlayEndpoint(web_rtc_play::Spec),
58}
59
60#[derive(
64 AsRef,
65 Clone,
66 Debug,
67 Display,
68 Eq,
69 From,
70 Hash,
71 Into,
72 Ord,
73 PartialEq,
74 PartialOrd,
75 RefCast,
76)]
77#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
78#[cfg_attr(feature = "serde", serde(transparent))]
79#[from(Box<str>, &str, String, web_rtc_play::Id, web_rtc_publish::Id)]
80#[into(Box<str>, String, web_rtc_play::Id, web_rtc_publish::Id)]
81#[repr(transparent)]
82pub struct Id(Box<str>);
83
84impl AsRef<web_rtc_play::Id> for Id {
85 fn as_ref(&self) -> &web_rtc_play::Id {
86 web_rtc_play::Id::ref_cast(&self.0)
87 }
88}
89
90impl AsRef<web_rtc_publish::Id> for Id {
91 fn as_ref(&self) -> &web_rtc_publish::Id {
92 web_rtc_publish::Id::ref_cast(&self.0)
93 }
94}