use crate::common::error::{DecodeWarning, JpegError};
pub trait ErrorHandler: Send + Sync {
fn error_exit(&self, err: &JpegError) -> ! {
panic!("JPEG fatal error: {err}");
}
fn emit_warning(&self, _warning: &DecodeWarning) {}
fn trace(&self, _level: u8, _msg: &str) {}
}
pub struct DefaultErrorHandler;
impl ErrorHandler for DefaultErrorHandler {}
#[derive(Debug, Clone, Copy)]
pub struct ProgressInfo {
pub pass: u32,
pub total_passes: u32,
pub progress: f32,
}
pub trait ProgressListener: Send + Sync {
fn update(&self, info: ProgressInfo);
}
impl<F: Fn(ProgressInfo) + Send + Sync> ProgressListener for F {
fn update(&self, info: ProgressInfo) {
self(info);
}
}