Skip to content

Commit 72e3954

Browse files
mtovino-cloudflarezakcutner
authored andcommitted
update README example to match current implementation
- the .build() call is required to align with recent rework of serialization - 'Type' was unused The example is intended to match the one in 'engine/src/lib.rs' - which has also been updated to remove the unused 'Type' and also 'rustfmt' the .build() call.
1 parent b7bece8 commit 72e3954

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

engine/README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,25 @@ an executable IR and, finally, executing filters against provided values.
1212
## Example
1313

1414
```rust
15-
use wirefilter::{ExecutionContext, Scheme, Type};
15+
use wirefilter::{ExecutionContext, Scheme};
1616

1717
fn main() -> Result<(), Box<dyn std::error::Error>> {
1818
// Create a map of possible filter fields.
1919
let scheme = Scheme! {
2020
http.method: Bytes,
2121
http.ua: Bytes,
2222
port: Int,
23-
};
23+
}
24+
.build();
2425

2526
// Parse a Wireshark-like expression into an AST.
26-
let ast = scheme.parse(r#"
27-
http.method != "POST" &&
28-
not http.ua matches "(googlebot|facebook)" &&
29-
port in {80 443}
30-
"#)?;
27+
let ast = scheme.parse(
28+
r#"
29+
http.method != "POST" &&
30+
not http.ua matches "(googlebot|facebook)" &&
31+
port in {80 443}
32+
"#,
33+
)?;
3134

3235
println!("Parsed filter representation: {:?}", ast);
3336

engine/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66
//! # Example
77
//!
88
//! ```
9-
//! use wirefilter::{ExecutionContext, Scheme, Type};
9+
//! use wirefilter::{ExecutionContext, Scheme};
1010
//!
1111
//! fn main() -> Result<(), Box<dyn std::error::Error>> {
1212
//! // Create a map of possible filter fields.
1313
//! let scheme = Scheme! {
1414
//! http.method: Bytes,
1515
//! http.ua: Bytes,
1616
//! port: Int,
17-
//! }.build();
17+
//! }
18+
//! .build();
1819
//!
1920
//! // Parse a Wireshark-like expression into an AST.
2021
//! let ast = scheme.parse(

0 commit comments

Comments
 (0)