use std::sync::Arc;
use crate::bindings::convert::FerriResultExt;
use ferridriver::Video as CoreVideo;
use rquickjs::JsLifetime;
use rquickjs::class::Trace;
#[derive(JsLifetime, Trace)]
#[rquickjs::class(rename = "Video")]
pub struct VideoJs {
#[qjs(skip_trace)]
inner: Arc<CoreVideo>,
}
impl VideoJs {
#[must_use]
pub fn new(inner: Arc<CoreVideo>) -> Self {
Self { inner }
}
}
#[rquickjs::methods]
impl VideoJs {
#[qjs(rename = "path")]
pub async fn path(&self) -> rquickjs::Result<String> {
let path = self.inner.path().await.into_js()?;
Ok(path.to_string_lossy().into_owned())
}
#[qjs(rename = "saveAs")]
pub async fn save_as(&self, path: String) -> rquickjs::Result<()> {
self.inner.save_as(path).await.into_js()
}
#[qjs(rename = "delete")]
pub async fn delete(&self) -> rquickjs::Result<()> {
self.inner.delete().await.into_js()
}
}