icedwright-trace 0.0.1

The icedwright trace format: a deterministic .iwtrace archive of every step a test took, with its writer, reader and comparison
Documentation
use crate::blob::BlobHash;

/// Everything that can go wrong configuring, writing or reading a trace.
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum TraceError {
    /// An environment variable holds a value the configuration cannot use.
    #[error("{var}={value:?} is not valid: {expected}")]
    BadEnv {
        /// The variable.
        var: &'static str,
        /// What it held.
        value: String,
        /// What it may hold.
        expected: &'static str,
    },
    /// The trace was written in a format this reader does not know.
    #[error(
        "trace format {found} is newer than this reader ({supported}); it was written by icedwright {writer}"
    )]
    NewerFormat {
        /// The format in the trace.
        found: u32,
        /// The newest format this reader reads.
        supported: u32,
        /// The icedwright version that wrote it.
        writer: String,
    },
    /// A step refers to a blob the archive does not hold.
    #[error("missing blob {0}")]
    MissingBlob(BlobHash),
    /// Reading or writing failed.
    #[error(transparent)]
    Io(#[from] std::io::Error),
    /// The bytes are not a readable zip archive, or a member cannot be decompressed.
    #[error("corrupt archive: {0}")]
    Corrupt(String),
    /// The archive lacks a member every trace has.
    #[error("corrupt archive: no {0} member")]
    MissingMember(&'static str),
    /// A member holds something other than what the format says it holds.
    #[error("corrupt archive: {member}{}: {reason}", line.map(|l| format!(" line {l}")).unwrap_or_default())]
    BadMember {
        /// The member's name inside the archive.
        member: String,
        /// The one-based line, for line-oriented members.
        line: Option<usize>,
        /// What is wrong with it.
        reason: String,
    },
    /// A blob's content does not hash to its name.
    #[error("corrupt archive: {member} hashes to {found}")]
    BlobMismatch {
        /// The member's name inside the archive.
        member: String,
        /// The hash of what it holds.
        found: BlobHash,
    },
    /// Bytes given as a PNG are not one, or a frame could not be encoded.
    #[error("not a PNG: {0}")]
    Png(String),
    /// A source file path that cannot be stored under `source/`.
    #[error("source path {0:?} must be relative and stay inside the workspace")]
    BadSourcePath(String),
}