use std::time::Duration;
use serde_json::{Map, Value};
#[derive(Default, Clone)]
pub struct ConvertOptions {
pub(crate) conversion_options: Map<String, Value>,
pub(crate) category: Option<String>,
pub(crate) filename: Option<String>,
pub(crate) download_password: Option<String>,
pub(crate) output_index: usize,
pub(crate) timeout: Option<Duration>,
}
impl ConvertOptions {
pub fn new() -> Self {
Self::default()
}
pub fn conversion_options(mut self, options: Map<String, Value>) -> Self {
self.conversion_options = options;
self
}
pub fn option(mut self, key: impl Into<String>, value: impl Into<Value>) -> Self {
self.conversion_options.insert(key.into(), value.into());
self
}
pub fn category(mut self, category: impl Into<String>) -> Self {
self.category = Some(category.into());
self
}
pub fn filename(mut self, filename: impl Into<String>) -> Self {
self.filename = Some(filename.into());
self
}
pub fn download_password(mut self, password: impl Into<String>) -> Self {
self.download_password = Some(password.into());
self
}
pub fn output_index(mut self, index: usize) -> Self {
self.output_index = index;
self
}
pub fn timeout(mut self, d: Duration) -> Self {
self.timeout = Some(d);
self
}
}
#[derive(Default, Clone)]
pub struct AsyncOptions {
pub(crate) conversion_options: Map<String, Value>,
pub(crate) category: Option<String>,
pub(crate) filename: Option<String>,
pub(crate) download_password: Option<String>,
pub(crate) callback: Option<String>,
}
impl AsyncOptions {
pub fn new() -> Self {
Self::default()
}
pub fn conversion_options(mut self, options: Map<String, Value>) -> Self {
self.conversion_options = options;
self
}
pub fn option(mut self, key: impl Into<String>, value: impl Into<Value>) -> Self {
self.conversion_options.insert(key.into(), value.into());
self
}
pub fn category(mut self, category: impl Into<String>) -> Self {
self.category = Some(category.into());
self
}
pub fn filename(mut self, filename: impl Into<String>) -> Self {
self.filename = Some(filename.into());
self
}
pub fn download_password(mut self, password: impl Into<String>) -> Self {
self.download_password = Some(password.into());
self
}
pub fn callback(mut self, url: impl Into<String>) -> Self {
self.callback = Some(url.into());
self
}
}