pub trait ProgressCallback: Send {
// Required method
fn on_progress(&mut self, progress: &Progress);
// Provided method
fn should_cancel(&self) -> bool { ... }
}Expand description
Progress callback trait for monitoring encoding progress.
Implement this trait to receive real-time encoding progress updates and optionally support encoding cancellation.
§Examples
ⓘ
use ff_encode::{Progress, ProgressCallback};
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, Ordering};
struct MyProgressHandler {
cancelled: Arc<AtomicBool>,
}
impl ProgressCallback for MyProgressHandler {
fn on_progress(&mut self, progress: &Progress) {
println!("Encoded {} frames at {:.1} fps",
progress.frames_encoded,
progress.current_fps
);
}
fn should_cancel(&self) -> bool {
self.cancelled.load(Ordering::Relaxed)
}
}Required Methods§
Sourcefn on_progress(&mut self, progress: &Progress)
fn on_progress(&mut self, progress: &Progress)
Called when encoding progress is updated.
This method is called periodically during encoding to report progress. The frequency of calls depends on the encoding speed and frame rate.
§Arguments
progress- Current encoding progress information