Next: IP prefix matcher. There, I'm thinking about changing the API a little.
In iocaine 3, you constructed a matcher by doing Matcher.from_ip_prefixes(StringList.new().push("127.0.0.1/32")). You gave it a string list, and it made a matcher. Simple.
In iocaine 4, I can do this:
let matcher = matchers.IPPrefix.new([
[127.0.0.1 / 32, "localhost"]
]);
matcher.matches(127.0.0.1 / 32) // returns bool
matcher.longest_match(127.0.0.1 / 32) // returns Some("localhost")
The goal here is to be able to use the longest match's data part for logging, or... whatever else. Come to think of it...
match matcher.longest_match(127.0.0.1 / 32) {
Some(data) => { ... }
None => {},
}
That could also work, and then we only perform the lookup once. The downside is that if I'm only interested if it matches, I still have to unwrap it... so I guess the .matches() variant is still useful.