use super::*;
#[derive(Clone, Debug, PartialEq, PartialOrd)]
#[repr(transparent)]
pub struct PerformanceMark {
inner: PerformanceEntry,
}
impl FromVal for PerformanceMark {
fn from_val(v: &Any) -> Self {
PerformanceMark {
inner: PerformanceEntry::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 PerformanceMark {
type Target = PerformanceEntry;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl core::ops::DerefMut for PerformanceMark {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<Any> for PerformanceMark {
fn as_ref(&self) -> &Any {
&self.inner
}
}
impl AsMut<Any> for PerformanceMark {
fn as_mut(&mut self) -> &mut Any {
&mut self.inner
}
}
impl From<PerformanceMark> for Any {
fn from(s: PerformanceMark) -> Any {
let handle = s.inner.as_handle();
core::mem::forget(s);
Any::take_ownership(handle)
}
}
impl From<&PerformanceMark> for Any {
fn from(s: &PerformanceMark) -> Any {
s.inner.clone().into()
}
}
jsbind::utils::impl_dyn_cast!(PerformanceMark);
impl PerformanceMark {
pub fn detail(&self) -> Any {
self.inner.get("detail").as_::<Any>()
}
}
impl PerformanceMark {
pub fn new(mark_name: &JsString) -> PerformanceMark {
Self {
inner: Any::global("PerformanceMark")
.new(&[mark_name.into()])
.as_::<PerformanceEntry>(),
}
}
}
impl PerformanceMark {
pub fn new_with_mark_options(
mark_name: &JsString,
mark_options: &PerformanceMarkOptions,
) -> PerformanceMark {
Self {
inner: Any::global("PerformanceMark")
.new(&[mark_name.into(), mark_options.into()])
.as_::<PerformanceEntry>(),
}
}
}