use super::*;
#[derive(Clone, Debug, PartialEq, PartialOrd)]
#[repr(transparent)]
pub struct RTCSessionDescription {
inner: Any,
}
impl FromVal for RTCSessionDescription {
fn from_val(v: &Any) -> Self {
RTCSessionDescription {
inner: Any::from_val(v),
}
}
fn take_ownership(v: AnyHandle) -> Self {
Self::from_val(&Any::take_ownership(v))
}
fn as_handle(&self) -> AnyHandle {
self.inner.as_handle()
}
}
impl core::ops::Deref for RTCSessionDescription {
type Target = Any;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl core::ops::DerefMut for RTCSessionDescription {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<Any> for RTCSessionDescription {
fn as_ref(&self) -> &Any {
&self.inner
}
}
impl AsMut<Any> for RTCSessionDescription {
fn as_mut(&mut self) -> &mut Any {
&mut self.inner
}
}
impl From<RTCSessionDescription> for Any {
fn from(s: RTCSessionDescription) -> Any {
let handle = s.inner.as_handle();
core::mem::forget(s);
Any::take_ownership(handle)
}
}
impl From<&RTCSessionDescription> for Any {
fn from(s: &RTCSessionDescription) -> Any {
s.inner.clone().into()
}
}
jsbind::utils::impl_dyn_cast!(RTCSessionDescription);
impl RTCSessionDescription {
pub fn type_(&self) -> RTCSdpType {
self.inner.get("type").as_::<RTCSdpType>()
}
}
impl RTCSessionDescription {
pub fn sdp(&self) -> JsString {
self.inner.get("sdp").as_::<JsString>()
}
}
impl RTCSessionDescription {
pub fn new(description_init_dict: &RTCSessionDescriptionInit) -> RTCSessionDescription {
Self {
inner: Any::global("RTCSessionDescription")
.new(&[description_init_dict.into()])
.as_::<Any>(),
}
}
}
impl RTCSessionDescription {
pub fn to_json(&self) -> RTCSessionDescriptionInit {
self.inner
.call("toJSON", &[])
.as_::<RTCSessionDescriptionInit>()
}
}