vmgstool/
vmgs_json.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

//! Schema definitions for JSON files generated by HvGuestState from a VMGSv1 file

use serde::Deserialize;
use serde::Serialize;
use std::collections::HashMap;

pub const BIOS_LOADER_DEVICE_ID: &str = "ac6b8dc1-3257-4a70-b1b2-a9c9215659ad";

#[derive(Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct Version {
    pub major: u32,
    pub minor: u32,
}

#[derive(Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct Device {
    pub version: Version,
    pub r#type: String,
    pub states: HashMap<String, State>,
}

#[derive(Serialize, Deserialize)]
#[serde(untagged)]
pub enum State {
    #[serde(rename_all = "PascalCase")]
    Nvram {
        vendors: HashMap<String, NvramVendor>,
        last_update_time: String,
    },
    Other(serde_json::Value),
}

#[derive(Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct NvramVendor {
    pub variables: HashMap<String, NvramVariable>,
}

#[derive(Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct NvramVariable {
    pub attributes: u32,
    pub data: Vec<u8>,
}

#[derive(Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct RuntimeState {
    pub version: Version,
    pub devices: HashMap<String, Device>,
}