xsd_parser/models/meta/
mod.rs

1//! The `meta` module contains all [`MetaType`] related definitions and structures.
2//!
3//! This module represents the internal type system used after schema interpretation,
4//! serving as an intermediate form between raw XML schema and Rust code generation.
5//! It is produced by the [`Interpreter`](crate::Interpreter) and optionally
6//! optimized by the [`Optimizer`](crate::Optimizer).
7
8mod attribute;
9mod base;
10mod complex;
11mod custom;
12mod dynamic;
13mod element;
14mod enumeration;
15mod reference;
16mod simple;
17mod type_;
18mod type_eq;
19mod types;
20mod union;
21
22use std::ops::{Bound, Range};
23
24pub use self::attribute::{AnyAttributeMeta, AttributeMeta, AttributeMetaVariant, AttributesMeta};
25pub use self::base::Base;
26pub use self::complex::{ComplexMeta, GroupMeta};
27pub use self::custom::{CustomDefaultImpl, CustomMeta};
28pub use self::dynamic::DynamicMeta;
29pub use self::element::{AnyMeta, ElementMeta, ElementMetaVariant, ElementMode, ElementsMeta};
30pub use self::enumeration::{EnumerationMeta, EnumerationMetaVariant, EnumerationMetaVariants};
31pub use self::reference::ReferenceMeta;
32pub use self::simple::{SimpleMeta, WhiteSpace};
33pub use self::type_::{BuildInMeta, MetaType, MetaTypeVariant};
34pub use self::type_eq::TypeEq;
35pub use self::types::{MetaTypes, ModuleMeta, SchemaMeta};
36pub use self::union::{UnionMeta, UnionMetaType, UnionMetaTypes};
37
38/// Constrains defined by the different facets of a type.
39#[derive(Debug, Clone, Eq, PartialEq, Hash)]
40pub struct Constrains {
41    /// Range the value should be in.
42    pub range: Range<Bound<String>>,
43
44    /// Number of total digits the value maximal should have.
45    pub total_digits: Option<usize>,
46
47    /// Number of fraction digits the value maximal should have.
48    pub fraction_digits: Option<usize>,
49
50    /// Regex pattern the value should fulfill.
51    pub patterns: Vec<String>,
52
53    /// The minimum length the value should have.
54    pub min_length: Option<usize>,
55
56    /// The maximum length the value should have.
57    pub max_length: Option<usize>,
58
59    /// Defines the whitespace handling.
60    pub whitespace: WhiteSpace,
61}
62
63impl Default for Constrains {
64    fn default() -> Self {
65        Self {
66            range: Range {
67                start: Bound::Unbounded,
68                end: Bound::Unbounded,
69            },
70            total_digits: None,
71            fraction_digits: None,
72            patterns: Vec::new(),
73            min_length: None,
74            max_length: None,
75            whitespace: WhiteSpace::default(),
76        }
77    }
78}