pub struct FacetSet {Show 14 fields
pub length: Option<LengthFacet>,
pub min_length: Option<MinLengthFacet>,
pub max_length: Option<MaxLengthFacet>,
pub patterns: Vec<Vec<PatternFacet>>,
pub enumeration: Option<EnumerationFacet>,
pub whitespace: Option<WhitespaceFacet>,
pub min_inclusive: Option<MinInclusiveFacet>,
pub max_inclusive: Option<MaxInclusiveFacet>,
pub min_exclusive: Option<MinExclusiveFacet>,
pub max_exclusive: Option<MaxExclusiveFacet>,
pub total_digits: Option<TotalDigitsFacet>,
pub fraction_digits: Option<FractionDigitsFacet>,
pub assertions: Vec<AssertionFacet>,
pub explicit_timezone: Option<ExplicitTimezoneFacet>,
}Expand description
Complete set of facets for a simple type
A FacetSet collects all constraining facets that apply to a simple type. Facets are accumulated during type derivation.
Fields§
§length: Option<LengthFacet>§min_length: Option<MinLengthFacet>§max_length: Option<MaxLengthFacet>§patterns: Vec<Vec<PatternFacet>>§enumeration: Option<EnumerationFacet>§whitespace: Option<WhitespaceFacet>§min_inclusive: Option<MinInclusiveFacet>§max_inclusive: Option<MaxInclusiveFacet>§min_exclusive: Option<MinExclusiveFacet>§max_exclusive: Option<MaxExclusiveFacet>§total_digits: Option<TotalDigitsFacet>§fraction_digits: Option<FractionDigitsFacet>§assertions: Vec<AssertionFacet>§explicit_timezone: Option<ExplicitTimezoneFacet>Implementations§
Source§impl FacetSet
impl FacetSet
Sourcepub fn set_length(
&mut self,
value: u64,
fixed: FacetFixed,
source: Option<SourceRef>,
)
pub fn set_length( &mut self, value: u64, fixed: FacetFixed, source: Option<SourceRef>, )
Set length facet
Sourcepub fn set_min_length(
&mut self,
value: u64,
fixed: FacetFixed,
source: Option<SourceRef>,
)
pub fn set_min_length( &mut self, value: u64, fixed: FacetFixed, source: Option<SourceRef>, )
Set minLength facet
Sourcepub fn set_max_length(
&mut self,
value: u64,
fixed: FacetFixed,
source: Option<SourceRef>,
)
pub fn set_max_length( &mut self, value: u64, fixed: FacetFixed, source: Option<SourceRef>, )
Set maxLength facet
Sourcepub fn add_pattern(
&mut self,
value: String,
source: Option<SourceRef>,
xsd_version: XsdVersion,
regex_compat: RegexCompat,
) -> FacetResult<()>
pub fn add_pattern( &mut self, value: String, source: Option<SourceRef>, xsd_version: XsdVersion, regex_compat: RegexCompat, ) -> FacetResult<()>
Add a pattern facet (compiles the pattern) at the current
derivation step. Multiple consecutive add_pattern calls on the
same FacetSet are treated as alternatives (OR’d) within a single
step; a new step is opened by inherit_from / merge_with_base.
Sourcepub fn add_pattern_unchecked(
&mut self,
value: String,
source: Option<SourceRef>,
)
pub fn add_pattern_unchecked( &mut self, value: String, source: Option<SourceRef>, )
Add a pattern facet without compiling (for deferred validation),
at the current derivation step. See add_pattern for the OR/AND
semantics across multiple calls.
Sourcepub fn compile_patterns(
&mut self,
xsd_version: XsdVersion,
regex_compat: RegexCompat,
) -> FacetResult<()>
pub fn compile_patterns( &mut self, xsd_version: XsdVersion, regex_compat: RegexCompat, ) -> FacetResult<()>
Compile all uncompiled patterns. Returns the first error encountered.
xsd_version selects the Unicode-category semantics for \p{X}: V1_0
pins to Unicode 3.0; V1_1 passes through to the backend.
regex_compat controls grammar leniency (see PatternFacet::compile).
Sourcepub fn add_enumeration(&mut self, value: String, source: Option<SourceRef>)
pub fn add_enumeration(&mut self, value: String, source: Option<SourceRef>)
Add an enumeration value
Sourcepub fn set_whitespace(
&mut self,
value: WhitespaceMode,
fixed: FacetFixed,
source: Option<SourceRef>,
)
pub fn set_whitespace( &mut self, value: WhitespaceMode, fixed: FacetFixed, source: Option<SourceRef>, )
Set whitespace facet
Sourcepub fn set_min_inclusive(
&mut self,
value: String,
fixed: FacetFixed,
source: Option<SourceRef>,
)
pub fn set_min_inclusive( &mut self, value: String, fixed: FacetFixed, source: Option<SourceRef>, )
Set minInclusive facet
Sourcepub fn set_max_inclusive(
&mut self,
value: String,
fixed: FacetFixed,
source: Option<SourceRef>,
)
pub fn set_max_inclusive( &mut self, value: String, fixed: FacetFixed, source: Option<SourceRef>, )
Set maxInclusive facet
Sourcepub fn set_min_exclusive(
&mut self,
value: String,
fixed: FacetFixed,
source: Option<SourceRef>,
)
pub fn set_min_exclusive( &mut self, value: String, fixed: FacetFixed, source: Option<SourceRef>, )
Set minExclusive facet
Sourcepub fn set_max_exclusive(
&mut self,
value: String,
fixed: FacetFixed,
source: Option<SourceRef>,
)
pub fn set_max_exclusive( &mut self, value: String, fixed: FacetFixed, source: Option<SourceRef>, )
Set maxExclusive facet
Sourcepub fn set_total_digits(
&mut self,
value: u32,
fixed: FacetFixed,
source: Option<SourceRef>,
)
pub fn set_total_digits( &mut self, value: u32, fixed: FacetFixed, source: Option<SourceRef>, )
Set totalDigits facet
Sourcepub fn set_fraction_digits(
&mut self,
value: u32,
fixed: FacetFixed,
source: Option<SourceRef>,
)
pub fn set_fraction_digits( &mut self, value: u32, fixed: FacetFixed, source: Option<SourceRef>, )
Set fractionDigits facet
Sourcepub fn add_assertion(
&mut self,
test: String,
xpath_default_namespace: Option<String>,
ns_snapshot: NamespaceContextSnapshot,
source: Option<SourceRef>,
)
pub fn add_assertion( &mut self, test: String, xpath_default_namespace: Option<String>, ns_snapshot: NamespaceContextSnapshot, source: Option<SourceRef>, )
Add an assertion facet (XSD 1.1)
Sourcepub fn set_explicit_timezone(
&mut self,
value: ExplicitTimezone,
fixed: FacetFixed,
source: Option<SourceRef>,
)
pub fn set_explicit_timezone( &mut self, value: ExplicitTimezone, fixed: FacetFixed, source: Option<SourceRef>, )
Set explicitTimezone facet (XSD 1.1)
Sourcepub fn inherit_from(&mut self, base: &FacetSet)
pub fn inherit_from(&mut self, base: &FacetSet)
Merge facets from a base type (for type derivation by restriction)
Inherited facets are only set if not already defined in this facet set.
The fixed attribute is preserved from the base type.
Note: This method does not validate that derived facets are more restrictive.
Use merge_with_base() for full validation.
Sourcepub fn merge_with_base(&self, base: &FacetSet) -> FacetResult<FacetSet>
pub fn merge_with_base(&self, base: &FacetSet) -> FacetResult<FacetSet>
Merge base type facets with derived type facets, validating derivation rules.
This method enforces XSD derivation by restriction rules:
- Fixed facets cannot be overridden with different values
- Derived facets must be more restrictive than base facets
- Patterns are cumulative (ANDed together)
- Enumerations must be subsets of base enumerations
Returns a new FacetSet combining base and derived facets, or an error if the derivation rules are violated.
Sourcepub fn validate_string(&self, value: &str) -> FacetResult<()>
pub fn validate_string(&self, value: &str) -> FacetResult<()>
Validate a string value against all applicable facets
This validates length, pattern, enumeration, and whitespace facets. Numeric bounds and digit facets require parsed values and are not validated by this method.
Sourcepub fn validate_string_patterns_enums(&self, value: &str) -> FacetResult<()>
pub fn validate_string_patterns_enums(&self, value: &str) -> FacetResult<()>
Validate only pattern and enumeration facets on a string value. Used for list types where length facets are checked separately as item count.
Sourcepub fn validate_patterns_only(&self, value: &str) -> FacetResult<()>
pub fn validate_patterns_only(&self, value: &str) -> FacetResult<()>
Validate only pattern facets (no enumeration, no length). Used when enumeration must be checked in value space rather than lexically.
Sourcepub fn validate_enum_value_space(
&self,
is_match: impl Fn(&str) -> bool,
display: &str,
) -> FacetResult<()>
pub fn validate_enum_value_space( &self, is_match: impl Fn(&str) -> bool, display: &str, ) -> FacetResult<()>
Validate enumeration in value space using a caller-supplied match predicate.
is_match(enum_str) returns true if the instance value equals the given
enumeration lexical value. display is used in the error message on failure.
Sourcepub fn validate_decimal(&self, value: &Decimal) -> FacetResult<()>
pub fn validate_decimal(&self, value: &Decimal) -> FacetResult<()>
Validate a decimal value against numeric facets
Sourcepub fn validate_float(&self, value: f32) -> FacetResult<()>
pub fn validate_float(&self, value: f32) -> FacetResult<()>
Validate a float value against numeric bounds facets
Sourcepub fn validate_double(&self, value: f64) -> FacetResult<()>
pub fn validate_double(&self, value: f64) -> FacetResult<()>
Validate a double value against numeric bounds facets
Sourcepub fn validate_explicit_timezone(&self, has_timezone: bool) -> FacetResult<()>
pub fn validate_explicit_timezone(&self, has_timezone: bool) -> FacetResult<()>
Validate explicitTimezone constraint (XSD 1.1)
§Arguments
has_timezone- Whether the value has a timezone specified
Sourcepub fn validate_binary_length(&self, byte_count: u64) -> FacetResult<()>
pub fn validate_binary_length(&self, byte_count: u64) -> FacetResult<()>
Validate a binary value (hex or base64) against length facets
Sourcepub fn validate_list_length(&self, item_count: u64) -> FacetResult<()>
pub fn validate_list_length(&self, item_count: u64) -> FacetResult<()>
Validate a list value against length facets (item count)