pub trait SCRecordingOutputDelegate:
Send
+ Sync
+ 'static {
// Provided methods
fn recording_did_start(&self) { ... }
fn recording_did_fail(&self, _error: String) { ... }
fn recording_did_finish(&self) { ... }
}Expand description
Delegate for recording output events
Implement this trait to receive notifications about recording lifecycle events. Callbacks may arrive on different system threads, so implementations must synchronize shared mutable state internally.
§Examples
§Using a struct
use screencapturekit::recording_output::SCRecordingOutputDelegate;
struct MyRecordingDelegate;
impl SCRecordingOutputDelegate for MyRecordingDelegate {
fn recording_did_start(&self) {
println!("Recording started!");
}
fn recording_did_fail(&self, error: String) {
eprintln!("Recording failed: {}", error);
}
fn recording_did_finish(&self) {
println!("Recording finished!");
}
}§Using closures
Use RecordingCallbacks to create a delegate from closures:
use screencapturekit::recording_output::{
SCRecordingOutput, SCRecordingOutputConfiguration, RecordingCallbacks
};
use std::path::Path;
let config = SCRecordingOutputConfiguration::new().expect("create recording configuration")
.with_output_url(Path::new("/tmp/recording.mp4")).expect("output path is valid UTF-8 without NUL bytes");
let delegate = RecordingCallbacks::new()
.on_start(|| println!("Started!"))
.on_finish(|| println!("Finished!"))
.on_fail(|e| eprintln!("Error: {}", e));
let recording = SCRecordingOutput::new_with_delegate(&config, delegate);Provided Methods§
Sourcefn recording_did_start(&self)
fn recording_did_start(&self)
Called when recording starts successfully
Sourcefn recording_did_fail(&self, _error: String)
fn recording_did_fail(&self, _error: String)
Called when recording fails with an error
Sourcefn recording_did_finish(&self)
fn recording_did_finish(&self)
Called when recording finishes successfully
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".