icedwright-trace 0.0.2

The icedwright trace format: a deterministic .iwtrace archive of every step a test took, with its writer, reader and comparison
Documentation
//! `meta.json`: what the trace is of. Nothing in it changes between runs.

use icedwright_types::{ScaleFactor, Size, units::Logical};
use serde::{Deserialize, Serialize};

use crate::ids::WindowOrdinal;

/// The format this crate writes and the newest it reads.
pub const FORMAT: u32 = 1;

/// The icedwright version that writes traces; the workspace versions its crates together.
pub(crate) const WRITER: &str = env!("CARGO_PKG_VERSION");

/// What a trace is of, filled in by the harness.
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct TraceMeta {
    /// The test's name.
    pub test: String,
    /// The crate the test belongs to.
    pub crate_name: String,
    /// The iced version the app was built with.
    pub iced_version: String,
    /// Each window's size when the trace was written.
    pub windows: Vec<WindowMeta>,
    /// The theme's name.
    pub theme: Option<String>,
    /// The scale factor frames were rendered at.
    pub scale_factor: ScaleFactor,
    /// The test's failure message, if it failed.
    pub failure: Option<String>,
}

/// A window the trace saw.
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
pub struct WindowMeta {
    /// The window.
    pub window: WindowOrdinal,
    /// Its size in logical pixels.
    pub size: Logical<Size>,
}

/// The whole of `meta.json`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub(crate) struct MetaFile {
    pub(crate) format: u32,
    pub(crate) written_by: String,
    pub(crate) frames_dropped: u32,
    pub(crate) trace: TraceMeta,
}

/// The part of `meta.json` every format keeps, read first so a newer format is named rather
/// than misread.
#[derive(Debug, Deserialize)]
pub(crate) struct MetaHeader {
    pub(crate) format: u32,
    pub(crate) written_by: String,
}