use std::ops::{Deref, DerefMut};
use url::Url;
use crate::{IdBuf, Result, Stream};
use crate::video::Video as AsyncVideo;
#[derive(Clone, Debug, derive_more::Display, PartialEq)]
pub struct Video(pub(super) AsyncVideo);
impl Video {
#[inline]
pub fn from_url(url: &Url) -> Result<Self> {
Ok(Self(block!(AsyncVideo::from_url(url))?))
}
#[inline]
pub fn from_id(id: IdBuf) -> Result<Self> {
Ok(Self(block!(AsyncVideo::from_id(id))?))
}
#[inline]
pub fn into_streams(self) -> Vec<Stream> {
self.0.streams
}
}
impl Deref for Video {
type Target = AsyncVideo;
#[inline]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl DerefMut for Video {
#[inline]
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}