Skip to main content

Environment

Trait Environment 

Source
pub trait Environment {
    // Required methods
    fn today(&self) -> String;
    fn now(&self) -> String;

    // Provided methods
    fn secondary_instance(&self, _id: &str) -> Option<&Instance> { ... }
    fn choice_label(&self, _value: &str, _question_path: &str) -> Option<String> { ... }
}
Expand description

Anything the evaluator needs that the instance alone cannot answer: secondary instances for instance(), and the values today() and now() should return.

Time is injected rather than read from the clock so that evaluating the same form twice gives the same answer — a test that drifts at midnight is worse than no test.

Required Methods§

Source

fn today(&self) -> String

ISO date for today().

Source

fn now(&self) -> String

ISO datetime for now().

Provided Methods§

Source

fn secondary_instance(&self, _id: &str) -> Option<&Instance>

Source

fn choice_label(&self, _value: &str, _question_path: &str) -> Option<String>

The label a choice list gives to value for the question at question_path. Answered by whoever holds the form; a bare evaluator has no choice lists and says so.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§