cloudflare-soos 2.3.1

Helper tool for Cloudflare's enhanced HTTP/2 and HTTP/3 prioritization, which makes progressive images load faster. Supports JPEG, GIF, and PNG.
Documentation
use cloudflare_soos as soos;
use soos::jpeg;
use std::env;
use std::fs;
use std::process;

fn usage() -> ! {
    eprintln!("usage: scan image.jpg");
    process::exit(1)
}

fn main() {
    let mut args = env::args().skip(1);
    let input_path = args.next().unwrap_or_else(|| usage());
    let input_file = fs::read(input_path).expect("The specified input file could not be opened");

    let mut decoder = jpeg::Decoder::new(input_file.as_slice());
    let markers = decoder.decode().expect("Decode error");
    for m in markers {
        if let jpeg::MarkerData::Scan(s) = m.marker {
            println!("{}: {}-{}, {}, {};", s.component_indices.into_iter().map(|c| c.to_string()).collect::<Vec<_>>().join(","),
                s.spectral_selection.start(), s.spectral_selection.end(),
                s.successive_approximation_high, s.successive_approximation_low,
            );
        }
    }
}