Skip to main content

Finish

Trait Finish 

pub trait Finish<I, O, E> {
    // Required method
    fn finish(self) -> Result<(I, O), E>;
}
Available on crate feature rustls only.
Expand description

Helper trait to convert a parser’s result to a more manageable type

Required Methods§

fn finish(self) -> Result<(I, O), E>

converts the parser’s result to a type that is more consumable by error management libraries. It keeps the same Ok branch, and merges Err::Error and Err::Failure into the Err side.

warning: if the result is Err(Err::Incomplete(_)), this method will panic.

  • “complete” parsers: It will not be an issue, Incomplete is never used
  • “streaming” parsers: Incomplete will 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 either Ok(_), Err(Err::Error(_)) or Err(Err::Failure(_)), you can get out of the parsing loop and call finish() on the parser’s result

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

§

impl<I, O, E> Finish<I, O, E> for Result<(I, O), Err<E>>