ConstraintsEvaluator
public protocol ConstraintsEvaluator : AnyObject
The interface to the constraints evaluator component.
Implementations are responsible for evaluating all the constraints and returning information about those that are satisfied or not.
-
Return a human-readable descriptiong for the constraints of a single feature
Declaration
Swift
func description(for feature: ConditionalFeatureDefinition.Type) -> String
-
Set the constraints for a given feature, for later evaluation.
This is called when building the constraints from the DSL definitions
Declaration
Swift
func set(constraints: DeclaredFeatureConstraints, for feature: ConditionalFeatureDefinition.Type)
-
Called to see if the constraints evaluation result for a given feature should be cached. Some constraints my prevent caching.
- return:
true
if the feature’s evaluation can be cached long term.false
if it needs to be checked every time.
Declaration
Swift
func canCacheResult(for feature: ConditionalFeatureDefinition.Type) -> Bool
- return:
-
Evaluate the constraints for the feature and return the results of this, including information about all the declared constraints and whether or not they are active.
Note
Implementations should not cache anything. TheAvailabilityChecker
calls this function abnd cacnches its results and manages this via calls tocanCacheResult(for:)
which can veto caching of the evaluation.Declaration
Swift
func evaluate(for feature: ConditionalFeatureDefinition.Type) -> FeatureConstraintsEvaluation