Skip to main content

icedwright_trace/
meta.rs

1//! `meta.json`: what the trace is of. Nothing in it changes between runs.
2
3use icedwright_types::{ScaleFactor, Size, units::Logical};
4use serde::{Deserialize, Serialize};
5
6use crate::ids::WindowOrdinal;
7
8/// The format this crate writes and the newest it reads.
9pub const FORMAT: u32 = 1;
10
11/// The icedwright version that writes traces; the workspace versions its crates together.
12pub(crate) const WRITER: &str = env!("CARGO_PKG_VERSION");
13
14/// What a trace is of, filled in by the harness.
15#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
16pub struct TraceMeta {
17    /// The test's name.
18    pub test: String,
19    /// The crate the test belongs to.
20    pub crate_name: String,
21    /// The iced version the app was built with.
22    pub iced_version: String,
23    /// Each window's size when the trace was written.
24    pub windows: Vec<WindowMeta>,
25    /// The theme's name.
26    pub theme: Option<String>,
27    /// The scale factor frames were rendered at.
28    pub scale_factor: ScaleFactor,
29    /// The test's failure message, if it failed.
30    pub failure: Option<String>,
31}
32
33/// A window the trace saw.
34#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
35pub struct WindowMeta {
36    /// The window.
37    pub window: WindowOrdinal,
38    /// Its size in logical pixels.
39    pub size: Logical<Size>,
40}
41
42/// The whole of `meta.json`.
43#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
44pub(crate) struct MetaFile {
45    pub(crate) format: u32,
46    pub(crate) written_by: String,
47    pub(crate) frames_dropped: u32,
48    pub(crate) trace: TraceMeta,
49}
50
51/// The part of `meta.json` every format keeps, read first so a newer format is named rather
52/// than misread.
53#[derive(Debug, Deserialize)]
54pub(crate) struct MetaHeader {
55    pub(crate) format: u32,
56    pub(crate) written_by: String,
57}