pub enum Status<T> {
Complete(T),
Incomplete,
}Expand description
The pipeline’s verdict on the pending input: finished, or waiting for more.
The pipeline closure passed to Session::feed
returns a Status. Complete carries whatever the pipeline produced — a
parsed tree, an evaluated value, a list of diagnostics, or a Result of
those — and the session hands it straight back in
Feed::Complete. Because the check for completeness and the real work
are the same call, the pipeline parses each finished entry exactly once.
Return Complete for input that is wrong as well as input that is
right: a syntax error in the middle of a line will not be fixed by typing
more lines. Only input that ended too soon should be Incomplete; see
Input::is_incomplete for the usual test.
§Examples
use repl_lang::{Feed, Session, Status};
// A pipeline that treats a trailing backslash as a line continuation.
let pipeline = |input: repl_lang::Input<'_>| {
if input.text().trim_end().ends_with('\\') {
Status::Incomplete
} else {
Status::Complete(input.text().lines().count())
}
};
let mut session = Session::new();
assert!(matches!(session.feed("echo one \\", pipeline)?, Feed::Incomplete));
assert!(matches!(session.feed("two", pipeline)?, Feed::Complete { value: 2, .. }));Variants§
Complete(T)
The input is a whole entry. The session commits it and returns the
value in Feed::Complete.
Incomplete
The input stops partway through a construct. The session keeps it and calls the pipeline again with the next line appended.