use crate::client::Client;
use crate::image_handler::BinaryFormat;
use std::io::Result;
pub struct Features {
pub width: u32,
pub height: u32,
pub offset: bool,
pub px_gray: bool,
pub binary: Option<BinaryFormat>,
}
pub fn feature_detection(client: &mut Client) -> Result<Features> {
let (width, height) = client.read_screen_size()?;
let mut features = Features {
width,
height,
offset: false,
px_gray: false,
binary: None,
};
let help_text = client.read_help()?;
for line in help_text.split('\n') {
let lowered = line.to_lowercase();
let trimmed = lowered.trim_start();
if trimmed.starts_with("offset") {
features.offset = true
} else if trimmed.starts_with("px x y gg") || trimmed.starts_with("grayscale") {
features.px_gray = true
} else if trimmed.contains("pbxyrgba") || trimmed.contains("pbxxyyrgba") {
features.binary = Some(BinaryFormat::CoordLERGBA)
}
}
Ok(features)
}