pub trait FinishIResult<I, O, E> {
// Required methods
fn finish(self) -> Result<O, E>;
fn finish_err(self) -> Result<(I, O), E>;
}Expand description
Extension trait to convert a parser’s IResult to a more manageable type
Required Methods§
Sourcefn finish(self) -> Result<O, E>
fn finish(self) -> Result<O, E>
Converts the parser’s IResult to a type that is more consumable by callers.
Errors if the parser is not at the end of input. See
FinishIResult::finish_err if the remaining input is needed.
§Panic
If the result is Err(Err::Incomplete(_)), this method will panic.
- “complete” parsers: It will not be an issue,
Incompleteis never used - “streaming” parsers:
Incompletewill be returned if there’s not enough data for the parser to decide, and you should gather more data before parsing again. Once the parser returns eitherOk(_),Err(Err::Error(_))orErr(Err::Failure(_)), you can get out of the parsing loop and callfinish_err()on the parser’s result
Sourcefn finish_err(self) -> Result<(I, O), E>
fn finish_err(self) -> Result<(I, O), E>
Converts the parser’s IResult to a type that is more consumable by errors.
It keeps the same Ok branch, and merges Err::Error and Err::Failure into the Err
side.
§Panic
If the result is Err(Err::Incomplete(_)), this method will panic as Err::Incomplete
should only be set when the input is InputIsStreaming<false> which this isn’t implemented
for.