router_prefilter
Fast prefix-based prefiltering for router pattern matching.
This crate provides efficient prefiltering of route matchers by extracting and indexing literal prefixes from patterns.
Usage
use RouterPrefilter;
use ;
let routes = vec!;
let mut prefilter = new;
for in routes.into_iter.enumerate
let matches: = prefilter.possible_matches.collect;
assert_eq!;
How It Works
The prefilter analyzes route matchers to extract literal prefixes and builds an efficient data structure for fast lookup.
The route matcher must implement the Matcher trait, and must call the specified functions on the passed visitor.
This can include nesting, multiple patterns ANDed and ORed together, etc.
If we are able to find a small set of prefixes where one must match at the begining of the actual string in order for the overall pattern to match, those found prefixes will be used as a prefilter.
e.g. path startsWith "/abc" OR path matchesRegex "^/ef[gh]": the path must start with either /abc, /efg or /efh.
Alternations which cannot be proved to start with anything will cause prefiltering to be impossible for that route.
e.g. path startsWith "/abc" OR path endsWith "zzz": prefiltering is impossible because the path could start with anything.