escl-scan
Example:
extern crate escl_scan;
extern crate serde_xml_rs;
fn main() {
let scanner_base_path = "192.168.2.5"; let scan_resolution = 300; let destination_file = "output.jpg";
let scanner_capabilities = escl_scan::get_scanner_capabilities(&scanner_base_path);
let scan_settings: escl_scan::structs::ScanSettings = escl_scan::structs::ScanSettings {
version: "2.6".to_string(),
scan_regions: escl_scan::structs::ScanRegion {
x_offset: 0,
y_offset: 0,
width: scanner_capabilities.platen.platen_input_caps.max_width,
height: scanner_capabilities.platen.platen_input_caps.max_height,
content_region_units: "escl:ThreeHundredthsOfInches".to_string(),
},
input_source: "Platen".to_string(),
color_mode: "RGB24".to_string(),
x_resolution: scan_resolution,
y_resolution: scan_resolution,
};
let request_body = serde_xml_rs::to_string(&scan_settings).unwrap();
let scan_response = escl_scan::get_scan_response(scanner_base_path, request_body);
let download_url = format!(
"{}/NextDocument",
scan_response
.headers()
.get("location")
.unwrap()
.to_str()
.unwrap()
);
escl_scan::download_scan(&download_url, destination_file);
}