xsd_parser/types/info/
dynamic.rs

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