escl-scan

Crates.ioescl-scan
lib.rsescl-scan
version0.1.1
sourcesrc
created_at2019-12-26 09:42:21.879992
updated_at2019-12-29 11:52:00.8353
descriptionA library for scanning documents over LAN or Wi-Fi using eSCL protocol.
homepage
repositoryhttps://github.com/ElXreno/escl-scan
max_upload_size
id192433
size10,079
ElXreno (ElXreno)

documentation

README

escl-scan


Copr build status Travis-CI build status dependency status

Example:

extern crate escl_scan;
extern crate serde_xml_rs;

fn main() {
    // Define variables...
    let scanner_base_path = "192.168.2.5"; // IP or mDNS (for example "Printer.local." to printer
    let scan_resolution = 300; // DPI
    let destination_file = "output.jpg"; // I think you already know what it is for

    // Get scanner capabilities...
    let scanner_capabilities = escl_scan::get_scanner_capabilities(&scanner_base_path);

    // Create scan settings...
    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,
    };

    // Send scan request...
    let request_body = serde_xml_rs::to_string(&scan_settings).unwrap();
    let scan_response = escl_scan::get_scan_response(scanner_base_path, request_body);

    // Get scan url...
    let download_url = format!(
        "{}/NextDocument",
        scan_response
            .headers()
            .get("location")
            .unwrap()
            .to_str()
            .unwrap()
    );

    // Download scan...
    escl_scan::download_scan(&download_url, destination_file);
}
Commit count: 106

cargo fmt