pub struct Node {Show 38 fields
pub kind: Kind,
pub required: bool,
pub required_set: bool,
pub kind_set: bool,
pub skippable: bool,
pub silent: bool,
pub empty: bool,
pub nullable: bool,
pub has_default: bool,
pub default: Value,
pub literal: Option<Value>,
pub obj_children: IndexMap<String, Node>,
pub obj_rest: Option<Box<Node>>,
pub consumed: HashSet<String>,
pub obj_keys: Vec<Arc<str>>,
pub plain: bool,
pub arr_children: Vec<Node>,
pub arr_child: Option<Box<Node>>,
pub arr_rest: Option<Box<Node>>,
pub befores: Vec<Validator>,
pub afters: Vec<Validator>,
pub regexp: Option<Regex>,
pub regexp_src: String,
pub fault_msg: Option<String>,
pub arg_fault: bool,
pub list_mode: ListMode,
pub list: Vec<Node>,
pub disc: Option<Disc>,
pub exact_vals: Vec<Value>,
pub has_exact: bool,
pub define_name: Option<String>,
pub refer_name: Option<String>,
pub refer_fill: bool,
pub refer_strict: bool,
pub rename_to: Option<String>,
pub rename_keep: bool,
pub rename_claim: Vec<String>,
pub meta: IndexMap<String, Value>,
}Expand description
A node of the compiled tree.
Fields§
§kind: Kind§required: bool§required_set: bool§kind_set: boolThe kind was named by the spec (a type token, type_), as against
implied by a value: a key expression’s example keeps the named kind
and supplies the default alone.
skippable: boolOptional and no default injection (p in TypeScript).
silent: boolErrors raised on or below this node are dropped (e: false).
empty: boolThe empty string is allowed.
nullable: boolAn explicit null is accepted as the value.
has_default: bool§default: ValueInjected for a missing optional property.
literal: Option<Value>The declarative value the node was built from, when it was one.
obj_children: IndexMap<String, Node>Object children, in the order the spec declared them.
obj_rest: Option<Box<Node>>The shape of an unknown key (an open object); none for a closed one.
consumed: HashSet<String>The keys a closed object accepts: its declared keys, the targets of its renames and the sources they claim. Set when the tree is prepared.
obj_keys: Vec<Arc<str>>The declared keys in order, shared with the paths that name them. Set when the tree is prepared.
plain: boolNothing but the structural check applies to a present value: no validator, rename, regexp or silence. Set when the tree is prepared, and lets a walk judge such a value in place.
arr_children: Vec<Node>The fixed positions of a tuple.
arr_child: Option<Box<Node>>The shape of every element after the fixed positions.
arr_rest: Option<Box<Node>>A Rest appended to an array.
befores: Vec<Validator>§afters: Vec<Validator>§regexp: Option<Regex>The pattern of a Regexp node.
regexp_src: StringThe pattern as written, in the shared subset: what renders and exports.
fault_msg: Option<String>A Fault message overriding the structural text.
arg_fault: boolMade by a builder given a wrong argument, as against a deliberate
fault: the string form refuses such a node.
list_mode: ListMode§list: Vec<Node>§disc: Option<Disc>A Discriminated union: the tag it chooses by, and its branch names, which are the list in that order.
exact_vals: Vec<Value>§has_exact: bool§define_name: Option<String>§refer_name: Option<String>§refer_fill: bool§refer_strict: bool§rename_to: Option<String>§rename_keep: bool§rename_claim: Vec<String>§meta: IndexMap<String, Value>Free-form metadata from x$$ sidecar keys.
Implementations§
Source§impl Node
impl Node
pub fn required(self) -> Node
pub fn optional(self) -> Node
Sourcepub fn default_to(self, dval: impl Into<Value>) -> Node
pub fn default_to(self, dval: impl Into<Value>) -> Node
Optional with the default; named to leave Default::default alone.
An untyped node is built over the default instead, and so takes the
default’s kind, keeping the checks and flags it carried.
pub fn skip(self) -> Node
pub fn ignore(self) -> Node
pub fn empty(self) -> Node
pub fn nullable(self) -> Node
pub fn open(self) -> Node
pub fn closed(self) -> Node
pub fn child(self, child: impl Into<Spec>) -> Node
pub fn rest(self, child: impl Into<Spec>) -> Node
pub fn fault(self, msg: impl Into<String>) -> Node
pub fn never(self) -> Node
Sourcepub fn type_(self, kind: impl Into<TypeRef>) -> Node
pub fn type_(self, kind: impl Into<TypeRef>) -> Node
Adopt the reference type’s kind and its required, skippable and
default state. Structural children are deliberately not copied:
type_(Object) is a closed object and type_(Array) accepts any
elements.