pub struct UnionSpec {
pub branches: Vec<UnionBranch>,
}Expand description
— Discriminated union —
Inferred-tag sum. Each branch declares a rule that the decoder uses to identify values belonging to that branch from the raw underlying value.
Portable schema-construction contract:
- branch
tags are unique within the union, - string-pattern discriminators (
prefix/suffix/contains/regex) require a branch body whose canonical raw JSON representation is a string (string-type,url-type,path-type, or arefresolving to one), field-equalsrequires a record-shaped branch body that declares the referenced field; a literal additionally requires that field to have a canonical raw JSON string representation,field-absentrequires a record-shaped branch body that does not declare the referenced field,- byte-identical regex text is rejected first as duplicate syntax, without making a semantic claim about the regex language,
- every remaining pair of discriminator rules is classified as overlapping, disjoint, or indeterminate. Overlapping pairs are rejected; disjoint and indeterminate pairs are accepted. Runtime decoders still reject a raw value that matches multiple accepted branches.
The canonical pair classification is symmetric and based only on the raw discriminator rules; branch body schemas do not refine it:
- two prefixes overlap exactly when either prefixes the other,
- two suffixes overlap exactly when either suffixes the other,
- every prefix/suffix, prefix/contains, suffix/contains, and contains/contains pair overlaps,
- a string-pattern rule and a record-shaped rule are disjoint because a raw JSON value cannot be both a string and an object,
- field-equals rules on different fields overlap; on the same field they are disjoint only when both literals are present and differ,
- every pair of field-absent rules overlaps,
- field-equals and field-absent are disjoint on the same field and overlap on different fields,
- after the duplicate-syntax check above, every pair containing a regex and another string-pattern rule is indeterminate and accepted. No portable semantic regex-overlap analysis is attempted because SDK regex dialects differ.
Fields§
§branches: Vec<UnionBranch>Trait Implementations§
Auto Trait Implementations§
impl Freeze for UnionSpec
impl RefUnwindSafe for UnionSpec
impl Send for UnionSpec
impl Sync for UnionSpec
impl Unpin for UnionSpec
impl UnsafeUnpin for UnionSpec
impl UnwindSafe for UnionSpec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more