chdman → libchdman-rs mapping

May 1, 2026 · View on GitHub

Quick reference for porting code that previously shelled out to the chdman CLI. Each row maps a chdman subcommand and its commonly-used flags to the equivalent Rust API. For full detail on each module see format-modules.md.

Subcommand map

chdmanlibchdman-rs
chdman createhd[hd::create_from_path] / [hd::create_from_reader]
chdman extracthd[hd::extract_to_path] / [hd::extract_to_writer]
chdman createraw[hd::create_from_reader] with custom HdCreateOptions (no geometry)
chdman extractraw[hd::extract_to_path] (no geometry round-trip needed)
chdman createdvd[dvd::create_from_iso] / [dvd::create_from_reader]
chdman extractdvd[dvd::extract_to_iso] / [dvd::extract_to_writer]
chdman createcd[cd::create_from_cue] / [cd::create_from_iso]
chdman extractcd[cd::extract_to_cue] (multi-track) / [cd::extract_to_iso] (MODE1 only)
chdman copy[copy::copy]
chdman info[Chd::info] returns a ChdInfo snapshot
chdman verify[Chd::verify]
chdman addmeta[Chd::write_metadata]
chdman delmeta[Chd::delete_metadata]
chdman dumpmeta[Chd::read_metadata] (+ [MetadataIter])
chdman creategd / extractgdDeferred — see TODO.md
chdman createld / createav / extractld / extractavDeferred — see TODO.md

Flag map

chdman flagRust equivalent
-c <spec> / --compressionopts.codecs = parse_codec_spec(spec)?
-c noneopts.codecs = [0; 4]
-hs <bytes> / --hunksizeopts.hunk_size = bytes
-us <bytes> / --unitsizeHdCreateOptions::unit_size
-chs C,H,S / --chsHdCreateOptions::geometry = Some(HdGeometry { … })
-ident <file> / --identHdCreateOptions::ident = Some(bytes)
-i <file> / --inputcreate_from_path(in_path, …)
-o <file> / --outputcreate_from_path(…, out_path, …)
-ib <bytes> / --inputbytesopts.logical_size = bytes
-f / --forceDelete the output file yourself before calling create — the API never overwrites
Cancellation (Ctrl+C)cancel: &dyn Fn() -> bool returning true
Progress outputprogress: &mut dyn FnMut(CompressionProgress) (creation) or &mut dyn FnMut(u64) (extraction)

Defaults

The Rust defaults match chdman's defaults so that Default::default() produces equivalent output to running chdman with no flags:

FormatHunk sizeUnit sizeCodecs
HD4096512[zlib, 0, 0, 0]
DVD40962048[lzma, zlib, huff, flac]
CD195842448[cdlz, cdzl, cdfl, 0]
copysource'ssource's[0; 4] (uncompressed)

What's not exposed

  • The chdman CLI itself. This crate is a library; the binary is not reimplemented.
  • v3/v4 CHD creation. Reading legacy CHDs via Chd::open works fine, but chdman has effectively retired creating those formats and so has libchdman-rs.
  • chdman's interactive prompts (e.g. confirming output overwrite, asking for parent CHD passwords). The Rust API never prompts — callers decide.

Example: porting a chdman createcd invocation

chdman createcd -i game.cue -o game.chd -c cdlz,cdfl,cdzl

becomes

use libchdman_rs::cd::{create_from_cue, CdCreateOptions};
use libchdman_rs::parse_codec_spec;
use std::path::Path;

create_from_cue(
    Path::new("game.cue"),
    Path::new("game.chd"),
    CdCreateOptions {
        codecs: parse_codec_spec("cdlz,cdfl,cdzl")?,
        ..CdCreateOptions::default()
    },
    &mut |_p| {},
    &|| false,
)?;