use anyhow::Result;
use crate::Browser;
use crate::browser::browser_config::BrowserConfig;
pub struct BrowserBuilder {
config: BrowserConfig,
}
impl BrowserBuilder {
pub fn new() -> Self {
Self {
config: BrowserConfig::new()
.expect("Failed to create default browser config")
}
}
pub fn headless(mut self, headless: bool) -> Self {
self.config.headless = headless;
self
}
pub async fn build(self) -> Result<Browser> {
Browser::create_browser(self.config).await
}
}
impl Default for BrowserBuilder {
fn default() -> Self {
Self::new()
}
}