Skip to main content

CriterionTest

Trait CriterionTest 

pub trait CriterionTest:
    Send
    + Sync
    + 'static {
    // Required method
    fn test(
        &self,
        criterion: &dyn CriterionContext,
    ) -> Result<bool, CriterionTestError>;
}
Expand description

A mod’s predicate for its advancement trigger, supplied as an Arc<dyn CriterionTest> to PlayerRef::trigger_criterion.

The game calls it synchronously for each open criterion, before testing the criterion’s player predicate. It keeps neither the test nor its context after the trigger returns. The native and wasm interfaces are generated from this trait, not separate implementations. Wasm predicates run synchronously through a scoped loan of the triggering import’s store, including in an already running group. They share the outer call’s execution budget and memory limit; the context expires when the predicate returns.

Required Methods§

fn test( &self, criterion: &dyn CriterionContext, ) -> Result<bool, CriterionTestError>

Whether the mod’s part of this criterion passes. A callback that cannot run refuses with a typed error, rather than silently answering that the criterion did not match.

Trait Implementations§

§

impl Wire for Box<dyn CriterionTest>

§

const MIN: usize = 8

Minimum encoded size, used to reject impossible collection lengths.
§

fn put(&self, out: &mut Writer)

Encodes this value, recording failures on the writer.
§

fn put_owned(self, out: &mut Writer)

Consumes owned data when a resource’s ownership must cross the boundary.
§

fn take(input: &mut Reader<'_>) -> Result<Box<dyn CriterionTest>, WireError>

Decodes one value, leaving any following bytes for the caller.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§