Skip to main content

FacetSet

Struct FacetSet 

Source
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

Source

pub fn new() -> Self

Create a new empty facet set

Source

pub fn is_empty(&self) -> bool

Check if the facet set is empty (no facets defined)

Source

pub fn set_length( &mut self, value: u64, fixed: FacetFixed, source: Option<SourceRef>, )

Set length facet

Source

pub fn set_min_length( &mut self, value: u64, fixed: FacetFixed, source: Option<SourceRef>, )

Set minLength facet

Source

pub fn set_max_length( &mut self, value: u64, fixed: FacetFixed, source: Option<SourceRef>, )

Set maxLength facet

Source

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.

Source

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.

Source

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).

Source

pub fn add_enumeration(&mut self, value: String, source: Option<SourceRef>)

Add an enumeration value

Source

pub fn set_whitespace( &mut self, value: WhitespaceMode, fixed: FacetFixed, source: Option<SourceRef>, )

Set whitespace facet

Source

pub fn set_min_inclusive( &mut self, value: String, fixed: FacetFixed, source: Option<SourceRef>, )

Set minInclusive facet

Source

pub fn set_max_inclusive( &mut self, value: String, fixed: FacetFixed, source: Option<SourceRef>, )

Set maxInclusive facet

Source

pub fn set_min_exclusive( &mut self, value: String, fixed: FacetFixed, source: Option<SourceRef>, )

Set minExclusive facet

Source

pub fn set_max_exclusive( &mut self, value: String, fixed: FacetFixed, source: Option<SourceRef>, )

Set maxExclusive facet

Source

pub fn set_total_digits( &mut self, value: u32, fixed: FacetFixed, source: Option<SourceRef>, )

Set totalDigits facet

Source

pub fn set_fraction_digits( &mut self, value: u32, fixed: FacetFixed, source: Option<SourceRef>, )

Set fractionDigits facet

Source

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)

Source

pub fn set_explicit_timezone( &mut self, value: ExplicitTimezone, fixed: FacetFixed, source: Option<SourceRef>, )

Set explicitTimezone facet (XSD 1.1)

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn validate_decimal(&self, value: &Decimal) -> FacetResult<()>

Validate a decimal value against numeric facets

Source

pub fn validate_float(&self, value: f32) -> FacetResult<()>

Validate a float value against numeric bounds facets

Source

pub fn validate_double(&self, value: f64) -> FacetResult<()>

Validate a double value against numeric bounds facets

Source

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
Source

pub fn validate_binary_length(&self, byte_count: u64) -> FacetResult<()>

Validate a binary value (hex or base64) against length facets

Source

pub fn validate_list_length(&self, item_count: u64) -> FacetResult<()>

Validate a list value against length facets (item count)

Trait Implementations§

Source§

impl Clone for FacetSet

Source§

fn clone(&self) -> FacetSet

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FacetSet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for FacetSet

Source§

fn default() -> FacetSet

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> MaybeSendSync for T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.