pub struct TestEvaluator { /* private fields */ }Expand description
A test evaluator that allows setting features for testing purposes.
Implementations§
Source§impl TestEvaluator
impl TestEvaluator
Sourcepub fn new() -> TestEvaluator
pub fn new() -> TestEvaluator
Create a new TestEvaluator.
Sourcepub fn set_feature<T: TestFeature>(&self, feature: &str, enabled: T)
pub fn set_feature<T: TestFeature>(&self, feature: &str, enabled: T)
Set the state of a feature.
The feature can be set to any value that implements TestFeature, which
allows for complex logic to determine if a feature is enabled. TestFeature
is automatically implemented for bool, Option<bool> and
Fn(&Context) -> impl TestFeature.
Sourcepub fn clear_feature(&self, feature: &str)
pub fn clear_feature(&self, feature: &str)
Unset a feature.
Trait Implementations§
Source§impl Default for TestEvaluator
impl Default for TestEvaluator
Source§impl Evaluator for TestEvaluator
impl Evaluator for TestEvaluator
Source§fn is_enabled(&self, feature: &str, _context: &Context) -> Option<bool>
fn is_enabled(&self, feature: &str, _context: &Context) -> Option<bool>
Checks if a feature is enabled in the given context. Read more
Source§fn on_new_context(&self, context: ContextRef<'_>, fields: Fields<'_>)
fn on_new_context(&self, context: ContextRef<'_>, fields: Fields<'_>)
Called when a new context is created. Read more
Source§fn on_registration(&self)
fn on_registration(&self)
Called when the evaluator is registered. Read more
Source§fn on_close_context(&self, context: ContextRef<'_>)
fn on_close_context(&self, context: ContextRef<'_>)
Called when a context is closed. Read more
Source§fn into_ref(self) -> EvaluatorRefwhere
Self: Sized + 'static,
fn into_ref(self) -> EvaluatorRefwhere
Self: Sized + 'static,
Converts the evaluator into an
EvaluatorRef. Read moreAuto Trait Implementations§
impl !Freeze for TestEvaluator
impl RefUnwindSafe for TestEvaluator
impl Send for TestEvaluator
impl Sync for TestEvaluator
impl Unpin for TestEvaluator
impl UnwindSafe for TestEvaluator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more