openconfiguration/
material_index.rs

1use std::collections::HashMap;
2
3use serde::{Deserialize, Serialize};
4
5use crate::material::Material;
6
7#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
8#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
9#[cfg_attr(feature = "schema", schemars(deny_unknown_fields))]
10#[serde(rename_all = "camelCase")]
11/**
12 * An external Material index.
13 */
14pub struct MaterialIndex {
15    /**
16     * The optional attribute provides a partial URI to be added to all
17     * relative asset uris. A valid base path should normally start with
18     * https:// or file://, and end with either a slash or the path sepa-
19     * rator character of the operating system.
20     */
21    pub base_path: Option<String>,
22
23    /**
24     * The mandatory attribute provides unique content hashes for assets
25     * that are directly referenced in the OC data set. The specific hash
26     * algorithm is unspecified. It may be an MD5 hash of the binary
27     * content for instance. But low-res assets may use the same hash as
28     * the originals, they are derived from. So, the only operation that is
29     * legal for hash, is to compare them with an optionally existing one.
30     */
31    #[serde(
32        deserialize_with = "crate::utils::deserialize_optional_map_without_null_values",
33        default
34    )]
35    pub hashes: Option<HashMap<String, String>>,
36
37    /**
38     * The mandatory attribute provides an embedded Material index.
39     */
40    #[serde(
41        deserialize_with = "crate::utils::deserialize_map_without_null_values",
42        default
43    )]
44    pub materials: HashMap<String, Material>,
45}