use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum Theme {
Light,
Dark,
}
impl std::fmt::Display for Theme {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Light => write!(f, "light"),
Self::Dark => write!(f, "dark"),
}
}
}
impl std::str::FromStr for Theme {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().as_str() {
"light" => Ok(Self::Light),
"dark" => Ok(Self::Dark),
_ => Err(format!("Unknown theme: {s}. Use 'light' or 'dark'")),
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ThemedImageOptions {
pub width: u32,
pub height: u32,
pub full_page: bool,
pub dismiss_popups: bool,
}
impl Default for ThemedImageOptions {
fn default() -> Self {
Self {
width: 1920,
height: 1080,
full_page: true,
dismiss_popups: true,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct DualThemeResult {
#[serde(skip)]
pub light: Vec<u8>,
#[serde(skip)]
pub dark: Vec<u8>,
pub url: String,
pub width: u32,
pub height: u32,
pub light_size: usize,
pub dark_size: usize,
}
#[allow(clippy::unused_async)]
pub async fn capture_dual_theme_screenshots(
url: &str,
_options: &ThemedImageOptions,
) -> crate::Result<DualThemeResult> {
let _absolute_url = if url.starts_with("http") {
url.to_string()
} else {
format!("https://{url}")
};
Err(crate::WebCaptureError::ScreenshotError(
"Dual-theme screenshot capture requires Chrome/Chromium. Install it and enable browser-commander features.".to_string()
))
}