Trait EvaluationContext

Source
pub trait EvaluationContext: Send + 'static {
    type Rng: Rng;

    // Required methods
    fn get_rng(&mut self) -> Self::Rng;
    fn now(&self) -> DateTime<Utc>;
    fn evaluation_start(&mut self);
    fn cache_get<K: Serialize, C: DeserializeOwned>(
        &mut self,
        key: &K,
    ) -> Result<Option<C>>;
    fn cache_set<K: Serialize, C: Serialize>(
        &mut self,
        key: &K,
        content: &C,
    ) -> Result<()>;
}
Expand description

Context passed through builtin evaluation

Required Associated Types§

Source

type Rng: Rng

The type of random number generator used by this context

Required Methods§

Source

fn get_rng(&mut self) -> Self::Rng

Get a rand::Rng

Source

fn now(&self) -> DateTime<Utc>

Get the current date and time

Source

fn evaluation_start(&mut self)

Notify the context on evaluation start, so it can clean itself up

Source

fn cache_get<K: Serialize, C: DeserializeOwned>( &mut self, key: &K, ) -> Result<Option<C>>

Get a value from the evaluation cache

§Errors

If the key failed to serialize, or the value failed to deserialize

Source

fn cache_set<K: Serialize, C: Serialize>( &mut self, key: &K, content: &C, ) -> Result<()>

Push a value to the evaluation cache

§Errors

If the key or the value failed to serialize

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§