pub trait Expression:
Send
+ Sync
+ Debug
+ DynClone {
// Required methods
fn resolve(&self, ctx: &mut Context<'_>) -> Resolved;
fn type_info(&self, state: &TypeState) -> TypeInfo;
// Provided methods
fn resolve_constant(&self, _state: &TypeState) -> Option<Value> { ... }
fn type_def(&self, state: &TypeState) -> TypeDef { ... }
fn apply_type_info(&self, state: &mut TypeState) -> TypeDef { ... }
fn format(&self) -> Option<String> { ... }
}Required Methods§
Sourcefn resolve(&self, ctx: &mut Context<'_>) -> Resolved
fn resolve(&self, ctx: &mut Context<'_>) -> Resolved
Resolve an expression to a concrete Value.
This method is executed at runtime.
An expression is allowed to fail, which aborts the running program.
Sourcefn type_info(&self, state: &TypeState) -> TypeInfo
fn type_info(&self, state: &TypeState) -> TypeInfo
Calculates the type state after an expression resolves, including the expression result itself.
This must be called with the initial TypeState.
Consider using apply_type_info instead if you want to just access
the expr result type, while updating an existing state.
Provided Methods§
Sourcefn resolve_constant(&self, _state: &TypeState) -> Option<Value>
fn resolve_constant(&self, _state: &TypeState) -> Option<Value>
Resolve an expression to a value without any context, if possible. This attempts to resolve expressions using only compile-time information.
This returns Some for static expressions, or None for dynamic expressions.
Sourcefn type_def(&self, state: &TypeState) -> TypeDef
fn type_def(&self, state: &TypeState) -> TypeDef
Resolve an expression to its TypeDef type definition.
This must be called with the initial TypeState.
Consider calling type_info instead if you want to capture changes in the type
state from side-effects.
Sourcefn apply_type_info(&self, state: &mut TypeState) -> TypeDef
fn apply_type_info(&self, state: &mut TypeState) -> TypeDef
Applies state changes from the expression to the given state, and returns the result type.