use log::warn;
use std::ops::Deref;
use web_sys::Url;
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub(crate) struct RecordingUrl(String);
impl RecordingUrl {
pub fn new() -> Self {
Self::default()
}
}
impl Drop for RecordingUrl {
fn drop(&mut self) {
if let Err(err) = Url::revoke_object_url(&self.0) {
warn!(
"Error occurred while attempting to revoke the Url used for recorded video: {:?}",
err
);
}
}
}
impl<S: Into<String>> From<S> for RecordingUrl {
fn from(string: S) -> Self {
Self(string.into())
}
}
impl Deref for RecordingUrl {
type Target = String;
fn deref(&self) -> &Self::Target {
&self.0
}
}