use serde::{Deserialize, Serialize};
use std::path::PathBuf;
fn default_true() -> Option<bool> {
Some(true)
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProxyConfig {
pub server: String,
pub bypass: Option<String>,
pub username: Option<String>,
pub password: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct BrowserProfile {
#[serde(default = "default_true")]
pub headless: Option<bool>,
pub user_data_dir: Option<PathBuf>,
pub allowed_domains: Option<Vec<String>>,
pub downloads_path: Option<PathBuf>,
#[serde(skip_serializing_if = "Option::is_none")]
pub proxy: Option<ProxyConfig>,
}
impl BrowserProfile {
pub fn new() -> Self {
Self::default()
}
pub fn with_headless(mut self, headless: bool) -> Self {
self.headless = Some(headless);
self
}
pub fn with_user_data_dir(mut self, dir: PathBuf) -> Self {
self.user_data_dir = Some(dir);
self
}
pub fn with_proxy(mut self, proxy: ProxyConfig) -> Self {
self.proxy = Some(proxy);
self
}
}