Skip to main content

DefaultValue

Enum DefaultValue 

Source
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: 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.

Fields

§name: String

Implementations§

Source§

impl DefaultValue

Source

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

Source

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.

Source

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

Source

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.

Source

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

Trait Implementations§

Source§

impl Clone for DefaultValue

Source§

fn clone(&self) -> Self

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 DefaultValue

Source§

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

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

impl<'de> Deserialize<'de> for DefaultValue

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for DefaultValue

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for DefaultValue

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for DefaultValue

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.