pub enum DefaultValue {
Bool(bool),
Integer(i64),
Float(f64),
String(String),
List(Vec<DefaultValue>),
Map(Vec<(String, DefaultValue)>),
Constructor {
name: String,
args: Vec<DefaultValue>,
},
}Expand description
The restricted <value expression> of a DEFAULT ON COMMIT clause
(CIP-262 Ap1): one typed form for validation, rendering, persistence,
and evaluation.
Variants§
Bool(bool)
Integer(i64)
Float(f64)
String(String)
List(Vec<DefaultValue>)
A list of allowed value expressions (all inner values static, or all evaluated at apply time – the CIP’s static/dynamic split is an evaluation-order optimization, not an observable difference, so this engine evaluates every default at apply time).
Map(Vec<(String, DefaultValue)>)
A map of allowed value expressions: a literal shape, but never a storable property value – only the storable/conformance checks reject it, never the shape check.
Constructor
One of the allowed type constructors with its (restricted) arguments.
Implementations§
Source§impl DefaultValue
impl DefaultValue
Sourcepub fn from_expr(e: &Expr) -> Result<Self, EngineError>
pub fn from_expr(e: &Expr) -> Result<Self, EngineError>
Captures the parser expression’s restricted shape (CIP-262): a
literal (a map among them – a literal shape whose storable
check, not its shape, rejects it, CIP-283 NE3), a list/map of
allowed values, or an allowed type constructor with allowed
arguments. null and every other expression shape are the two
CIP-262 rejection cases, as typed errors (the two CIP texts,
verbatim in message form).
Sourcepub fn is_storable(&self) -> bool
pub fn is_storable(&self) -> bool
Whether this value can be stored on a property: every literal leaf but a map (a map is only ever an argument of a constructor that consumes it), every list of storable values, and every constructor of the allowed set.
Sourcepub fn conforms_to(&self, declared: &TypeExpr) -> Result<bool, EngineError>
pub fn conforms_to(&self, declared: &TypeExpr) -> Result<bool, EngineError>
The CIP-262 conformance check: the default’s static type is allowed
under the property’s declared value type (a NOT NULL static type
under a nullable declared type is fine – a non-null value is
always allowed under a nullable type; the reverse is not). The
subsumption relation itself is the type lattice’s
(super::canon_allows, shared with CIP-266’s
restriction-only re-specification check).
Sourcepub fn render(&self) -> String
pub fn render(&self) -> String
The canonical form of the value expression (CIP-262 canonical
syntax’s CVE): string literals single-quoted (backslashes and
embedded quotes escaped), lists bracketed, map keys backticked and
sorted, constructors by name with their canonical arguments.
Sourcepub fn to_expr(&self) -> Expr
pub fn to_expr(&self) -> Expr
Rebuilds the parser expression for evaluation: the mechanical
inverse of DefaultValue::from_expr, used only to hand the
value to the engine’s own evaluator (and, from the persisted
model, to rebuild the body’s parser form).