pub trait Engine {
// Required methods
fn count<I>(&self, input: &I) -> Result<MatchCount, EngineError>
where I: Input;
fn indices<I, S>(&self, input: &I, sink: &mut S) -> Result<(), EngineError>
where I: Input,
S: Sink<MatchIndex>;
fn matches<I, S>(&self, input: &I, sink: &mut S) -> Result<(), EngineError>
where I: Input,
S: Sink<Match>;
}
Expand description
An engine that can run its query on a given input.
Required Methods§
sourcefn count<I>(&self, input: &I) -> Result<MatchCount, EngineError>where
I: Input,
fn count<I>(&self, input: &I) -> Result<MatchCount, EngineError>where I: Input,
Find the number of matches on the given Input
.
The result is equivalent to using matches
and counting the matches,
but in general is much more time and memory efficient.
Errors
An appropriate EngineError
is returned if the JSON input is malformed
and the syntax error is detected.
Please note that detecting malformed JSONs is not guaranteed. Some glaring errors like mismatched braces or double quotes are raised, but in general the result of an engine run on an invalid JSON is undefined. It is guaranteed that the computation terminates and does not panic.
sourcefn indices<I, S>(&self, input: &I, sink: &mut S) -> Result<(), EngineError>where
I: Input,
S: Sink<MatchIndex>,
fn indices<I, S>(&self, input: &I, sink: &mut S) -> Result<(), EngineError>where I: Input, S: Sink<MatchIndex>,
Find the starting indices of matches on the given Input
and write them to the Sink
.
The result is equivalent to using matches
and extracting the
[Match::span.start_idx
],
but in general is much more time and memory efficient.
Errors
An appropriate EngineError
is returned if the JSON input is malformed
and the syntax error is detected.
Please note that detecting malformed JSONs is not guaranteed. Some glaring errors like mismatched braces or double quotes are raised, but in general the result of an engine run on an invalid JSON is undefined. It is guaranteed that the computation terminates and does not panic.
sourcefn matches<I, S>(&self, input: &I, sink: &mut S) -> Result<(), EngineError>where
I: Input,
S: Sink<Match>,
fn matches<I, S>(&self, input: &I, sink: &mut S) -> Result<(), EngineError>where I: Input, S: Sink<Match>,
Find all matches on the given Input
and write them to the Sink
.
Errors
An appropriate EngineError
is returned if the JSON input is malformed
and the syntax error is detected.
Please note that detecting malformed JSONs is not guaranteed. Some glaring errors like mismatched braces or double quotes are raised, but in general the result of an engine run on an invalid JSON is undefined. It is guaranteed that the computation terminates and does not panic.