1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//! Library surface behind the `stuffr` binary.
//!
//! Two reasons it exists. [`cli::Cli`] is here so `tests/cli.rs` can
//! introspect it through `clap::CommandFactory`: the examples page's test
//! asserts every flag and subcommand clap knows about is mentioned on the
//! page, and doing that against the real `Cli` (rather than a hand-copied
//! list of flag names) keeps the assertion honest as the surface grows.
//! [`compat`] is here so that `main`, the integration tests and the `compat`
//! fuzz target all drive the same compatibility families (`bzip2` and
//! friends) and `install-links`. [`bench`](mod@bench) is here so its
//! harness, scoring and renderers can be tested with injected times: the CLI
//! tests run a debug binary, where `stuffr bench` refuses to time anything.
//! [`format_by_name`] is the `--format`/`--formats` lookup `main` and
//! `bench` share.
//!
//! None of this is a stable API; it is the binary's own code, kept public
//! for those callers. `bench` and `format_by_name` stay documented, as
//! `cli`, `compat` and `size` are, rather than `#[doc(hidden)]`: this
//! crate's docs are the binary's internals docs, and hiding two of its
//! modules would only make them harder to find.
/// Resolves a `--format` name against the registry. Shared by
/// `main`'s verbs and `stuffr bench`.
///
/// `FormatId` holds a `&'static str` so the registry can be built from
/// constants without allocation, but a flag value arrives at runtime as a
/// `String`. Rather than leak it to reach `'static`, look it up: the registry
/// already holds the `'static` id, and an unknown name gets a real error
/// naming what this build does have.