Skip to main content

segmentor/
lib.rs

1//! `segmentor`: a video-on-demand origin that packages MP4 files as HLS and DASH on demand.
2//!
3//! The crate is a library plus a thin binary. The library's public surface is deliberately
4//! small: [`run`] is the binary's entry point, and hidden helper modules expose the media pipeline
5//! to the fuzz target and the benchmark harness. Everything else is crate-private; see the implementation guide in `docs/` for a
6//! module-by-module description.
7
8#![forbid(unsafe_code)]
9
10use std::process::ExitCode;
11
12mod asset;
13mod cli;
14mod config;
15mod error;
16mod fmp4;
17mod http;
18mod media;
19mod mp4;
20mod observability;
21mod protocol;
22mod registry;
23mod resolver;
24mod segment;
25mod source;
26mod subtitle;
27#[cfg(test)]
28mod testutil;
29
30#[doc(hidden)]
31pub mod benchmarking;
32pub mod fuzzing;
33
34const APP_NAME: &str = "segmentor";
35
36/// Runs the command-line application with the process arguments.
37///
38/// Prints `segmentor: <error>` to standard error and returns a failure exit code if the
39/// command fails.
40pub async fn run() -> ExitCode {
41    match cli::run(std::env::args_os().skip(1)).await {
42        Ok(()) => ExitCode::SUCCESS,
43        Err(error) => {
44            eprintln!("{APP_NAME}: {error}");
45            ExitCode::FAILURE
46        }
47    }
48}
49
50#[cfg(test)]
51mod tests {
52    use super::APP_NAME;
53
54    #[test]
55    fn application_name_is_stable() {
56        assert_eq!(APP_NAME, "segmentor");
57    }
58}