Skip to main content

Crate specification_core

Crate specification_core 

Source
Expand description

Composable, strongly typed business rules.

A Specification evaluates a borrowed candidate. Specifications compose through Specification::and, Specification::or, and Specification::not without dynamic dispatch or heap allocation.

use specification_core::Specification;

let is_adult = |age: &u8| *age >= 18;
let is_senior = |age: &u8| *age >= 65;
let eligible = is_adult.and(is_senior.not());

assert!(eligible.is_satisfied_by(&42));
assert!(!eligible.is_satisfied_by(&70));

Structs§

AllOf
A borrowed collection evaluated with logical AND.
Always
A specification that always returns true.
And
A specification that requires both of two specifications to be satisfied.
AnyOf
A borrowed collection evaluated with logical OR.
AsyncAnd
An asynchronous specification that requires both operands to succeed.
AsyncNot
An asynchronous specification that negates another specification.
AsyncOr
An asynchronous specification that accepts either operand.
BoxedAsyncSpecification
An explicitly type-erased asynchronous specification.
BoxedSpecification
An explicitly type-erased, owned specification.
Cooldown
A specification satisfied after a named timestamp is at least one duration old.
EvaluationContext
Immutable input data for specifications that need counters, flags, time, and application-specific user data.
FirstMatch
Ordered, typed decisions selected by the first matching specification.
FixedClock
A clock fixed at one instant, useful for deterministic evaluation and tests.
Flag
A specification satisfied when a named context flag is true.
MaxCount
A specification satisfied while a named counter remains strictly below a maximum.
Never
A specification that always returns false.
Not
A specification that negates another specification’s result.
Or
A specification that requires either of two specifications to be satisfied.
SharedSpecification
An explicitly type-erased specification that can be shared across threads.

Traits§

AsyncSpecification
A runtime-neutral asynchronous rule over a borrowed, Sync candidate.
Clock
A deterministic source of evaluation time supplied by the caller.
DecisionSpecification
A rule that selects a typed decision for a candidate.
Specification
A deterministic boolean rule over a borrowed candidate.

Type Aliases§

BoxFuture
A boxed Send future used by the object-safe asynchronous adapter.