aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorOnur Gündüz <ogunduz@gmail.com>2026-09-29 17:32:03 +0200
committerOnur Gündüz <ogunduz@gmail.com>2026-09-29 17:32:03 +0200
commita489aaf4332df58886205cebeffb983819dfef96 (patch)
tree5d35976f7fabde55bd54d3a2b3d04924f62e1c30 /README.md
parent8b3aa7600b92c170e56c26c7b68f28158df76549 (diff)
downloadele-a489aaf4332df58886205cebeffb983819dfef96.tar.gz
ele-a489aaf4332df58886205cebeffb983819dfef96.zip
Restore Filterable usage and stable Rust installation
Diffstat (limited to 'README.md')
-rw-r--r--README.md32
1 files changed, 30 insertions, 2 deletions
diff --git a/README.md b/README.md
index d302f1d..505e82f 100644
--- a/README.md
+++ b/README.md
@@ -4,10 +4,11 @@ Parses and evaluates an [AIP-160](https://google.aip.dev/160)-style filter langu
## Install
-Rust 1.88 or newer is required. Clone the repository and install it with Cargo:
+Install [Rust](https://rustup.rs/), then run this from a repository checkout:
```bash
-cargo install --path . --locked
+rustup update stable
+cargo +stable install --path . --locked
```
## CLI usage
@@ -59,6 +60,33 @@ let record = json!({"state": "open", "priority": 5});
assert!(filter.evaluate(&record));
```
+For a custom type, expose its fields through `Filterable`:
+
+```rust
+use aif::{Filterable, Value, parse};
+
+struct Issue {
+ state: String,
+ priority: i64,
+}
+
+impl Filterable for Issue {
+ fn field(&self, name: &str) -> Option<Value<'_>> {
+ match name {
+ "state" => Some(Value::String(&self.state)),
+ "priority" => Some(Value::Int(self.priority)),
+ _ => None,
+ }
+ }
+}
+
+let expr = parse("state = open AND priority > 3").unwrap().unwrap();
+let filter = expr.compile().unwrap();
+let issue = Issue { state: "open".into(), priority: 5 };
+
+assert!(filter.evaluate(&issue));
+```
+
## License
Licensed under the [MIT License](LICENSE).