Trait Validator
trait Validator
This trait provides an extension interface for determining whether the current input buffer is valid.
Rustyline uses the method provided by this trait to decide whether hitting
the enter key will end the current editing session and return the current
line buffer to the caller of crate::Editor::readline or variants.
Provided Methods
fn validate(self: &Self, ctx: &mut ValidationContext<'_>) -> Result<ValidationResult>Takes the currently edited
inputand returns aValidationResultindicating whether it is valid or not along with an option message to display about the result. The most common validity check to implement is probably whether the input is complete or not, for instance ensuring that all delimiters are fully balanced.If you implement more complex validation checks it's probably a good idea to also implement a
crate::hint::Hinterto provide feedback about what is invalid.For auto-correction like a missing closing quote or to reject invalid char while typing, the input will be mutable (TODO).
fn validate_while_typing(self: &Self) -> boolConfigure whether validation is performed while typing or only when user presses the Enter key.
Default is
false.This feature is not yet implemented, so this function is currently a no-op
Implementors
impl Validator for MatchingBracketValidatorimpl Validator for ()