ccatoken/store/refvalues.rs
1// Copyright 2023 Contributors to the Veraison project.
2// SPDX-License-Identifier: Apache-2.0
3
4use super::platformrefvalue::PlatformRefValue;
5use super::realmrefvalue::RealmRefValue;
6use serde::{Deserialize, Serialize};
7use serde_json::Error;
8
9/// JSON format for CCA reference values (both platform and realm).
10#[derive(Deserialize, Serialize, Debug, Default)]
11pub struct RefValues {
12 pub platform: Option<Vec<PlatformRefValue>>,
13 pub realm: Option<Vec<RealmRefValue>>,
14}
15
16impl RefValues {
17 /// Parse CCA reference values from JSON
18 pub fn parse(j: &str) -> Result<Self, Error> {
19 let v: RefValues = serde_json::from_str(j)?;
20 // TODO: add validation of variable length fields
21 Ok(v)
22 }
23}