Skip to content

Iterator helper methods like inspect_errors() #66

@nathanbabcock

Description

@nathanbabcock

A common pattern when using this library is something like the following:

match event {
      FfmpegEvent::Error(e) | FfmpegEvent::Log(LogLevel::Error | LogLevel::Fatal, e) => {
        eprintln!("{e}");
      }
      // ...
}

It captures errors from three different sources (FFmpeg error, FFmpeg fatal, and library-level error). It's super useful while debugging. But it's pretty wordy, and not intuitive if you don't know about the different error types beforehand. It would great to introduce an inspect_errors() method which does this more conveniently, and allows chaining with the other iterator methods without writing a match statement.

command.iter().inspect_errors(|e| eprintln!(e))

Along the same lines, this could be standardized into two families of inspect_x and filter_x for errors, frames, chunks, logs, etc. The implementation might be a bit boilerplate-y since it would need a series of wrapping structs like InspectError (similar to std::iter::Inspect), but it would be very nice from the user side.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions