-
Notifications
You must be signed in to change notification settings - Fork 26
Description
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.