//! Exit codes of the `decode` and `verify` children, reserved away from 1 (generic failure), 101 (Rust //! panic) and signal deaths (reported separately by the parent). The parent maps them to //! the closed rejection reasons of STEP8_FILES_ANALYSIS II.7. pub const OK: i32 = 0; pub const USAGE: i32 = 2; pub const ENV_NOT_EMPTY: i32 = 10; pub const SANDBOX_FAILED: i32 = 11; pub const INPUT_TOO_LARGE: i32 = 12; pub const UNSUPPORTED_TYPE: i32 = 13; pub const DECODE_FAILED: i32 = 14; pub const DIMENSIONS: i32 = 15; pub const ENCODE_FAILED: i32 = 16; pub const OUTPUT_FAILED: i32 = 17; pub const INTERNAL: i32 = 18; /// The decoders' allocation or complexity budget was exceeded by the content. pub const RESOURCE_LIMIT: i32 = 19; /// The parent stopped its loop because a child reported a broken environment (R1). pub const CHILD_BROKEN: i32 = 20; /// The parent's watchdog found a stage past its deadline and exited (R1). pub const WATCHDOG: i32 = 21; /// The `verify` child could not read its framed input: a parent bug, never the content's. pub const FRAME_INVALID: i32 = 22; /// Codes that judge the content (the upload is refused). Every other non-zero code means /// the child's environment is broken (`Broken` outcome: the parent alerts rather than /// rejects). Explicit list on purpose: a new code never lands in the wrong class by /// accident, and no content can produce a "broken" code. pub fn is_content_rejection(code: i32) -> bool { matches!( code, INPUT_TOO_LARGE | UNSUPPORTED_TYPE | DECODE_FAILED | DIMENSIONS | RESOURCE_LIMIT ) } /// Stable name of an exit code for logs and tests. pub fn name(code: i32) -> &'static str { match code { OK => "ok", USAGE => "usage", ENV_NOT_EMPTY => "env_not_empty", SANDBOX_FAILED => "sandbox_failed", INPUT_TOO_LARGE => "input_too_large", UNSUPPORTED_TYPE => "unsupported_type", DECODE_FAILED => "decode_failed", DIMENSIONS => "dimensions", ENCODE_FAILED => "encode_failed", OUTPUT_FAILED => "output_failed", INTERNAL => "internal", RESOURCE_LIMIT => "resource_limit", CHILD_BROKEN => "child_broken", WATCHDOG => "watchdog", FRAME_INVALID => "frame_invalid", _ => "unknown", } }