#expression #validation #serde-json #rets #reso #rcp19

no-std rets_expression

从 RESO RCP19 实现RET S验证表达式

2个版本

0.1.1 2023年7月20日
0.1.0 2023年7月14日

#1324编码

Download history 843/week @ 2024-03-14 1044/week @ 2024-03-21 975/week @ 2024-03-28 1001/week @ 2024-04-04 1226/week @ 2024-04-11 697/week @ 2024-04-18 834/week @ 2024-04-25 814/week @ 2024-05-02 539/week @ 2024-05-09 1075/week @ 2024-05-16 871/week @ 2024-05-23 1193/week @ 2024-05-30 1343/week @ 2024-06-06 1319/week @ 2024-06-13 1170/week @ 2024-06-20 745/week @ 2024-06-27

4,681 每月下载量

MIT 许可证

110KB
2.5K SLoC

RESO传输小组RCP 19 (RETS验证表达式)的实现。

查看文档以了解用法。

查看“compliance-tests”文件夹中的合规性测试。


lib.rs:

RESO传输小组RCP 19 (RETS验证表达式)的实现。

示例

use rets_expression::{Expression, Engine, EvaluateContext};
use serde_json::json;

// Parse an expression
let expression = "MlsStatus .IN. ('Active', 'Pending') .AND. (ListPrice >= 1 .OR. LAST MlsStatus = 'Incomplete')"
    .parse::<Expression>()
    .unwrap();

// Create the property data to run the expression against
let value = json!({
    "MlsStatus": "Active",
    "ListPrice": 1000000
});
// Create the previous property data to run the expression against (for when the expression
// includes references to previous data, like `LAST FieldName`)
let previous_value = json!({
    "MlsStatus": "Incomplete",
    "ListPrice": 0
});

// Create a default engine and a context in which to evaluate the expression
let engine = Engine::default();
let context = EvaluateContext::new(&engine, &value).with_previous(&previous_value);

// Evaluate the expression!
let value = expression.apply(context).unwrap();
assert_eq!(value.into_owned(), json!(true));

依赖关系

~2.3–8.5MB
~61K SLoC