1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//! This crate provides a small-foorprint solution to evaluate comparisons, expressed as text, with a dynamically value-lookup.
//!
//! The comparisons can be written like normal rust-code.
//! For example:
//!
//! ```foo + 2 > 2 && bar != 42 || (baz == 47111 && barg * 42 <= 99) && foo >= bar - 5```.
//!
//! The only limitation at the moment is that you currently have to use a variable-name on the left-hand (WIP). Left-Hand values are not supported yet.
//!
//! Comparisons can be made against any [Value]-Type implemented:
//! - [Value::String] encapsulated in quotation marks
//! - [Value::Numeric] (internally [f64] but everything from u8 to f64 will be converted Into it automatically)
//! - [Value::Bool] which is simply a [bool]
//! - [Value::Time] (internally [chrono::NaiveTime]), encapsulated in quotation marks and expressed in form of "%H:%M:%S" as of NaiveTime::parse_from_str().
//! - [Value::Duration] as [chrono::Duration] encapsulated in quotation marks and represented in [humantime::Duration] (see [humantime::parse_duration] for formatting possibilities) for ease of use
//!
//! Value-Lookup is made through a given [Resolver]-trait internally so you are open to use what ever you like in the background to resolve variable-names to their value-representation.
//!
//! If you want to use an async resolver (see AsyncResolver), you have to enable the `async` feature.
//!
//! For laziness there is a [MapResolver] which implements [Resolver] and can be made [From] any [std::collections::HashMap] that contain a Key which is [AsRef]\<str> and values which can be made [Value]::[From].
//!
//! For the ease of use, an `crate::evaluate` function is implemented which just takes a string and compares using a given resolver.
//!
//! To have a more performant usage of this crate, use [crate::parse_tree] which produces a pre-parsed [Sequence] once.
//! This [Sequence] can then be used in subsequent calls to [crate::solve_tree] to evalaute the [Sequence] with current variable-values over and over again.
use Result;
/// Compute arithmetics on [Value]s
/// Compare [Value] against [Value]
/// Helper-Object to use [std::collections::HashMap] as [Resolver]
/// Parser to generate [Sequence] from a given text
/// Resolves name to [Value]
/// Sequence of comparisons
/// Solves [Sequence]
/// A generic value
pub use ;
pub use MapResolver;
pub use parse_tree;
pub use Resolver;
pub use Sequence;
pub use solve_tree;
pub use Value;
/// Evaluate string-`sequence` with the given [Resolver] resolver to a final bool-result.
/// This always parses the `sequence`-string, generates a [Sequence] and evaluats it using the given [Resolver].
/// Use this if the input-sequence is changing on the same logic. To have a better performing solution where
/// input-sequences do not change and where you just want to check a given logic against changing metrics, save the
/// output of [parse_tree] and throw it towards a value-changing [Resolver] in a [solve_tree] when needed.
pub use AsyncResolver;
/// Async-version of 'evaluate'
pub async