#![forbid(unsafe_code)] mod audio; mod demux; mod encode_audio; mod encode_video; mod image; mod mux; mod subs; mod video; use sha2::{Digest, Sha256}; use std::fmt::Display; use std::path::Path; const DOMAINS: [(&str, fn()); 8] = [ ("video", video::run), ("audio", audio::run), ("image", image::run), ("subs", subs::run), ("demux", demux::run), ("mux", mux::run), ("encode_video", encode_video::run), ("encode_audio", encode_audio::run), ]; pub fn hash(case: &str, bytes: &[u8]) { let digest = Sha256::digest(bytes); let hex: String = digest.iter().map(|b| format!("{b:02x}")).collect(); println!("{case}\t{hex}"); } pub fn text(case: &str, line: impl Display) { println!("{case}\t{line}"); } pub fn error(case: &str, err: impl Display) { println!("{case}\tERR {err}"); } pub fn guard(case: &str, f: impl FnOnce()) { if std::panic::catch_unwind(std::panic::AssertUnwindSafe(f)).is_err() { text(case, "PANIC"); } } pub fn name(path: &Path) -> String { let root = ec_testkit::root(); path.strip_prefix(&root).unwrap_or(path).display().to_string() } fn main() { std::panic::set_hook(Box::new(|_| {})); let wanted = std::env::args().nth(1).unwrap_or_default(); let mut ran = false; for (domain, run) in DOMAINS { if wanted == "all" || wanted == domain { run(); ran = true; } } if !ran { let names: Vec<&str> = DOMAINS.iter().map(|(domain, _)| *domain).collect(); eprintln!("usage: golden ", names.join("|")); std::process::exit(2); } }