xsd_parser/models/meta/
dynamic.rs

1//! Contains the [`DynamicMeta`] type information and all related types.
2
3use std::hash::Hasher;
4
5use crate::models::Ident;
6
7use super::{MetaTypes, TypeEq};
8
9/// Type information that contains data about dynamic types.
10#[derive(Default, Debug, Clone)]
11pub struct DynamicMeta {
12    /// Base type of the dynamic type.
13    pub type_: Option<Ident>,
14
15    /// List of derived types.
16    pub derived_types: Vec<Ident>,
17}
18
19impl TypeEq for DynamicMeta {
20    fn type_hash<H: Hasher>(&self, hasher: &mut H, types: &MetaTypes) {
21        let Self {
22            type_,
23            derived_types,
24        } = self;
25
26        type_.type_hash(hasher, types);
27        TypeEq::type_hash_slice(derived_types, hasher, types);
28    }
29
30    fn type_eq(&self, other: &Self, types: &MetaTypes) -> bool {
31        let Self {
32            type_,
33            derived_types,
34        } = self;
35
36        type_.type_eq(&other.type_, types)
37            && TypeEq::type_eq_iter(derived_types.iter(), other.derived_types.iter(), types)
38    }
39}